/** * 处理登录操作 * * @return Response * @auther yangyifan <*****@*****.**> */ public function postLogin(LoginFormRequest $request) { $login_status = AdminInfo::login($request->all()); switch ($login_status) { case 1: return $this->response(200, trans('response.success'), [], true, url('admin/home')); case -1: case -3: return $this->response(401, trans('response.admin_not_exists')); case -2: return $this->response(401, trans('response.admin_disable')); } //登陆失败 return $this->response(401, trans('response.unauthorized')); }
/** * 添加后台用户 * * @param Request $request * @auther yangyifan <*****@*****.**> */ public function postAdd(AdminInfoRequest $request) { $data = $request->all(); $data['password'] = bcrypt($data['password']); //写入数据 $affected_number = AdminInfoModel::create($data); return $affected_number->id > 0 ? $this->response(200, trans('response.add_success'), [], true, url('admin/admininfo/index')) : $this->response(400, trans('response.add_error'), [], false); }
/** * 用户退出 * * @return Response * @auther yangyifan <*****@*****.**> */ public function getLogout() { AdminInfo::logout(); $this->response(200, trans('response.success'), [], true, url('admin/login')); }