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