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