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