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)。
我在想什麼?可以不創建多個事件來實現這一點?