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