[], 'after' => ['publish', 'submit', 'approve'], ]; public function handle(NotificationWorkflowEvent $event) { $function = Str::camel($event->transition); return $this->$function($event); } /** * Sends a notification to the client when the $notification is submitted. * * @param NotificationWorkflowEvent $event The event object. * @return void */ public function submit(NotificationWorkflowEvent $event) { $client = $event->notification->client; Notification::send($client, new NotificationWorkflowNotification($event)); } /** * Sends a notification to the client when the $notification is published. * * @param NotificationWorkflowEvent $event The event object. * @return void */ public function publish(NotificationWorkflowEvent $event) { $client = $event->notification->client; Notification::send($client, new NotificationWorkflowNotification($event)); } /** * Sends a notification to the client when the $notification is approved. * * @param NotificationWorkflowEvent $event The event object. * @return void */ public function approve(NotificationWorkflowEvent $event) { $client = $event->notification->client; Notification::send($client, new NotificationWorkflowNotification($event)); } /** * Handles the $notification workflow event as a listener. * * @param NotificationWorkflowEvent $event The event object. * @return void */ public function asListener(NotificationWorkflowEvent $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); } } }