sent_at = Carbon::now(); // if user is int if (is_int($user)) { $user = (new User)->find($user); } $this->user = $user; $this->event = $event; if ($data instanceof Model) { $this->data = $data->toArray(); } else { $this->data = $data; } if (Auth::guard('module')->check()) { $this->module = Auth::guard('module')->user(); // if (isset($this->data['event'])) { // $this->event = $this->module->id . '.' . $this->data['event']; // } } // log if (config('app.env') != 'production') { Log::debug('Users Event', [ 'user' => $this->user->id, 'data' => $this->data, 'module' => $this->module, 'event' => $this->event, ]); } } public function broadcastOn(): PrivateChannel { return new PrivateChannel('users.'.$this->user->id); } public function broadcastAs(): string { return 'messages'; } }