[], 'after' => ['publish', 'submit', 'approve'], ]; public function handle(NoticeWorkflowEvent $event) { $function = Str::camel($event->transition); return $this->$function($event); } /** * Sends a notification to the client when the $notice is submitted. * * @param NoticeWorkflowEvent $event The event object. * @return void */ public function submit(NoticeWorkflowEvent $event) { $client = $event->$notice->client; Notification::send($client, new NoticeWorkflowNotification($event)); } /** * Sends a notification to the client when the $notice is published. * * @param NoticeWorkflowEvent $event The event object. * @return void */ public function publish(NoticeWorkflowEvent $event) { $client = $event->$notice->client; Notification::send($client, new NoticeWorkflowNotification($event)); } /** * Sends a notification to the client when the $notice is approved. * * @param NoticeWorkflowEvent $event The event object. * @return void */ public function approve(NoticeWorkflowEvent $event) { $client = $event->$notice->client; Notification::send($client, new NoticeWorkflowNotification($event)); } /** * Handles the $notice workflow event as a listener. * * @param NoticeWorkflowEvent $event The event object. * @return void */ public function asListener(NoticeWorkflowEvent $event) { if (($event->when == 'before' && in_array($event->transition, $this->allowedTransitions['before']) || $event->when == 'after' && in_array($event->transition, $this->allowedTransitions['after'])) ) { return $this->handle($event); } } }