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