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