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