college-courses/app/Http/Middleware/Admin.php

26 lines
512 B
PHP
Raw Permalink Normal View History

2024-10-15 10:15:40 +03:00
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class Admin
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (Auth::check() && (Auth()->user()->role === 'admin' || Auth()->user()->name === 'superadmin')) {
return $next($request);
}
return abort(403);
}
}