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