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