where($map)->first(); if (!$user) throw new Exception('', HttpStatus::USER_DOES_NOT_EXIST); if (!password_verify($password, $user->password)) throw new Exception('', HttpStatus::PASSWORDS_ERROR); return $user; } public function roles() { return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id'); } public function getRolesIdsAttribute() { return $this->roles->pluck('id')->toArray(); } public function getRolesNamesAttribute() { return $this->roles->pluck('display_name')->toArray(); } }