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