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