App\Modules\Files\Controllers\Admin\Files::filterRequests PHP Method

filterRequests() public method

Filter the incoming requests.
public filterRequests ( Nova\Routing\Route $route, Nova\Http\Request $request )
$route Nova\Routing\Route
$request Nova\Http\Request
    public function filterRequests(Route $route, Request $request)
    {
        // Store the Request instance for further processing.
        $this->request = $request;
        // Check the User Authorization.
        if (Auth::user()->hasRole('administrator')) {
            // The User is authorized; continue the Execution Flow.
            return null;
        }
        if ($request->ajax()) {
            // On an AJAX Request; just return Error 403 (Access denied)
            return Response::make('', 403);
        }
        // Redirect the User to his/hers Dashboard with a warning message.
        $status = __d('files', 'You are not authorized to access this resource.');
        return Redirect::to('admin/dashboard')->withStatus($status, 'warning');
    }