<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;


class isAdmin
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    protected $auth;
//    public function __construct(Guard $auth){
//        $this->auth = $auth;
//    }

    public function handle($request, Closure $next)
    {

        if (Auth::user() &&  Auth::user()->admin == 1) {
            return $next($request);
        }

        return redirect('/admin');
    }



}