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