<?php

namespace App\Http\Middleware;


use Illuminate\Support\Facades\Auth;
use App\Models\User;
use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class RoleMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  Closure(Request): (Response)  $next
     */
    public function handle(Request $request, Closure $next): Response
    {
        if (!Auth::check() ) {
            return redirect('/')->with('error', 'ليس لديك صلاحية الدخول');
        }
        return $next($request);
    }
}
