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