auth = $auth; } /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // $ip=$request->header('ali-cdn-real-ip'); // if (!$ip){ // $ip = $request->header('X-Real-IP'); // } // $address = Ip::find($ip); // $log = new UsersLog(); // 提前创建表、model // $log -> ip = $ip; // $log -> browser = Agent::browser(); // 浏览器名称 // $log -> platform = Agent::platform();// 操作系统 // $log -> device = Agent::device(); // 设备名称 // $log -> address = $address[0].$address[1].$address[2]; // $log -> is_phone = Agent::isPhone(); // $log -> time = Carbon::now()->toDateTimeString(); // $log -> created_at = Carbon::now()->toDateTimeString(); // $log -> updated_at = Carbon::now()->toDateTimeString(); // // 记录 用户信息 // if($this->auth->check()) { // if($this->auth->user()->id) { // $log -> user_id = (int) $this->auth->user()->id ?? null; //// $log -> phone = $this->auth->user()->mobile ?? null; // $log -> nickname = $this->auth->user()->nickname ?? null; // } // } // // 记录 路由 方法 数据 // $log -> path = $request->path(); // $log -> method = $request->method(); // $log -> input = json_encode($request->all(), JSON_UNESCAPED_UNICODE); // $log -> save(); # 记录日志 return $next($request); } }