public function attachRoleById($userId, $roleIds) { $user = $this->findWithTrashedById($userId); $user->roles()->sync($roleIds); return $this->model->withTrashed()->with(['roles'])->findOrFail($userId); }