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