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