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