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