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