[], 'after' => ['create'], ]; /** * Handle the AreaActionEvent. * * @param AreaActionEvent $event * @return mixed */ public function handle(AreaActionEvent $event) { $function = Str::camel($event->action); return $this->$function($event); } /** * Create a new $area. * * @param AreaActionEvent $event * @return void */ public function create(AreaActionEvent $event) { $client = $event->area->client; Notification::send($client, new AreaActionNotification($event)); } /** * Handle the AreaActionEvent as a listener. * * @param AreaActionEvent $event * @return mixed */ public function asListener(AreaActionEvent $event) { if ($this->isAllowed($event)) { return $this->handle($event); } } /** * Check if the event action is allowed. * * @param AreaActionEvent $event * @return bool */ private function isAllowed(AreaActionEvent $event) { if ($event->when == 'before' && !in_array($event->action, $this->allowedActions['before'])) { return false; } if (($event->when == 'after' && !in_array($event->action, $this->allowedActions['after'])) ) { return false; } return true; } }