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