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