1
我想记录什么时候某个客户端已经创建/更新/删除了事件。这可能没有创建所有行动的事件?我使用的是最新版本的laravel的(5.4个大气压)一个事件给多个处理程序 - laravel
事件:
class EventClient
{
use SerializesModels;
public $client;
public function __construct(Client $client)
{
$this->client = $client;
}
}
处理程序:
public function onCreateClient(EventClient $event) { //log }
public function onUpdateClient(EventClient $event) { //log }
public function subscribe($events)
{
$events->listen(
'App\Events\EventClient',
'App\Listeners\[email protected]'
);
$events->listen(
'App\Events\EventClient',
'App\Listeners\[email protected]'
);
}
型号我使用的默认保护$事件:
protected $events = [
'created' => EventClient::class,
'updated' => EventClient::class,
];
EventServiceProvider我用过订阅者
protected $subscribe = [
'App\Listeners\HandleClient',
];
当我创建/更新一些客户将其记录两次,显然他运行创建和更新事件,因为他使用相同的事件(EventClient)。
我在想什么?可以不创建多个事件来实现这一点?