<?php

namespace App\Http\Middleware;

use Closure;

class AuthApi
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {

        if (empty($request->input('token'))) {
            return responseToJson(-40412322); //token为空
        }
        $token = \App\Models\Setinfo::getsInfo(1000);
        if ($request->input('token') != $token) {
          //  return responseToJson(-40412422); //token错误
        }
        if (!defined('REMOTE_KEY')) {
            define('REMOTE_KEY', $token);
        }

        return $next($request);
    }
}
