auth = $auth; } /** * 司机端登录 * * @return \think\response\Json * @throws \Lettered\Support\Exceptions\FailedException */ public function login() { // 接收数据 $param = $this->request->param(); // 内置验证 $valid = $this->validate($param, [ 'mobile|手机号' => 'require|mobile', 'password|密码' => 'require', ]); // 错误 if (true !== $valid){ return IResponse::failure($valid); } // attempt $token = $this->auth->guard('taxi_user')->attempt($param); return $token ? IResponse::success([ 'token' => 'Bearer ' . $token, ], '登录成功') : IResponse::failure('登录失败'); } }