protected function removeUser(Request $request) { $userId = $request->request->get('userId'); if (!empty($userId)) { if (User::deleteByUserId($userId)) { UserRole::deleteByUserId($userId); Sharing::deleteByUserId($userId); return $this->success(); } } $this->abort(500, 'error.cannotRemoveUser'); }
public function getRoles() { if ($this->roles === null) { $this->roles = array_map(function (UserRole $role) { return $role->getRole(); }, UserRole::loadByUserId($this->userId)); } return $this->roles; }