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

26 lines
512 B
PHP

<?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);
}
}