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