App\Http\Middleware\RedirectIfNotAdmin::handle PHP Method

handle() public method

Handle an incoming request.
public handle ( Illuminate\Http\Request $request, Closure $next ) : mixed
$request Illuminate\Http\Request
$next Closure
return mixed
    public function handle($request, Closure $next)
    {
        if (!auth()->user()->hasRole('administrator')) {
            Session()->flash('flash_message_warning', 'Only Allowed for admins');
            return redirect()->back();
        }
        return $next($request);
    }
RedirectIfNotAdmin