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