[], 'after' => ['create'], ]; /** * Handle the FilingActionEvent. * * @param FilingActionEvent $event * @return mixed */ public function handle(FilingActionEvent $event) { $function = Str::camel($event->action); return $this->$function($event); } /** * Create a new $filing. * * @param FilingActionEvent $event * @return void */ public function create(FilingActionEvent $event) { $client = $event->filing->client; Notification::send($client, new FilingActionNotification($event)); } /** * Handle the FilingActionEvent as a listener. * * @param FilingActionEvent $event * @return mixed */ public function asListener(FilingActionEvent $event) { if ($this->isAllowed($event)) { return $this->handle($event); } } /** * Check if the event action is allowed. * * @param FilingActionEvent $event * @return bool */ private function isAllowed(FilingActionEvent $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; } }