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