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