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