<?php
namespace App\Http\Middleware;
use Closure;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use App\Models\WxAdmin;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Session;

class CheckAdminLogin
{
    /**
     *
     * @param $request
     * @param Closure $next
     * @return array|mixed
     */
    public function handle(Request $request, Closure $next)
    {
        if(!Auth::check()) return redirect(route('adminLogin'))->with( 'error', '用户登录信息失效，请重新登录');
        $request['userId'] = Auth::user()->id;
        $request['userName'] = Auth::user()->name;
        return $next($request);
    }
}
