<?php

namespace App\Http\Middleware;

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

class AgentMiddleware
{

    public function handle($request, Closure $next)
    {
        if(Auth::check() && Auth::user()->is_admin == 0)
        {
            return $next($request);

        }
        elseif(Auth::check() && Auth::user()->is_admin == 1)
        {

        return redirect()->route('admin.dashboard');

        }
        else{

            return back();
        }
    }
}
