helper = $helper; } /** * Handle the event. * * @param ProjectUserCreate $event * @return void */ public function handle(ProjectUserCreate $event) { $payload = $event->message; $new_user = User::findOrFail($payload->data->original->user_id); $project = Project::findOrFail($payload->data->original->project_id); $owners_id = request('_business_info')['info']['projects'][$project->id]['members']->reject(function ($item, $key) use ($new_user) { return $item['level'] < enum('levels.owner.id') || $key === $new_user->id; })->toArray(); $owners = User::whereIn('id', array_keys($owners_id))->get(); $users = $owners->prepend($new_user); $this->helper->makeNotif($payload, null, ['project' => $project->name, 'user' => $new_user->name] )->sendNotifications($users, 'critical'); } }