<?php

namespace App\Http\Middleware;

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

class RolSoporte
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = 'superadmin')
    {
        $user = Auth::guard($guard)->user();
        if ($user->soporte == 0) {
            return redirect()->route('superadmin.index');
        }
        return $next($request);
    }
}
