auth = $auth; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { $token=$request->header('authorization'); $helper=$request->header('helper',0); $token_end = explode('.',$token)[2]; if($this->auth->check()) { $user_id = (int) $this->auth->user()->id; if($helper==1){ $assit_id=Assit::where('token_end',$token_end)->where('agent_id',$user_id)->value('id'); if($assit_id){ // if('GET' != $request->method()){ $log = new AssitLog(); # 提前创建表、model $log->agent_id = $user_id; $log->assit_id = $assit_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->input = json_encode($request->all(), JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 // } }else{ return response()->json([ "code"=>451101, "msg"=>'登录状态异常,请重新登录', "message"=>'登录状态异常,请重新登录', "data"=>'登录状态异常,请重新登录', ], 200); } } } return $next($request); } }