<?php

namespace App\Http\Middleware;

use App\Tool\ToolFunc;
use Closure;
use Illuminate\Support\Facades\Auth;

class AdminLogin
{
    use ToolFunc;
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if (!Auth::guard('web')->check()) {
            return redirect('/web/login');
        }

        if (request()->isMethod('DELETE') || request()->isMethod('PUT')) {
            self::getPutValueHandle($request);
        }

        return $next($request);
    }
}
