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