<?php

namespace LaraBB\Admin\Middleware;

use Closure;
use Illuminate\Http\RedirectResponse;

/**
 * Class CheckAdmin
 * @package LaraBB\Admin\Middleware
 */
class CheckAdmin
{
    /**
     * @param $request
     * @param Closure $next
     * @return RedirectResponse|mixed
     */
    public function handle($request, Closure $next)
    {
        if(!$request->user()->isInGroup(['Administrator'])) {
            return redirect()->route('index');
        }

        return $next($request);
    }
}
