helper = $helper; } /** * Handle the event. * * @param TaskCreate $event * @return void */ public function handle(TaskCreate $event) { $payload = $event->message; if ($payload->data->original->assignee_id !== null) { $this->assigneeNotifHandler($payload); } if ($payload->data->original->approver_id !== null) { $this->approverNotifHandler($payload); } } public function assigneeNotifHandler($payload) { $user = User::findOrFail($payload->data->original->assignee_id); $task = Task::findOrFail($payload->data->original->id); $this->helper->makeNotif($payload, 'assignee', ['task' => $task->title]) ->sendNotifications($user, 'critical'); } public function approverNotifHandler($payload) { $user = User::findOrFail($payload->data->original->approver_id); $task = Task::findOrFail($payload->data->original->id); $this->helper->makeNotif($payload, 'approver', ['task' => $task->title]) ->sendNotifications($user, 'critical'); } }