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