%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/rental/app/Http/Middleware/
Upload File :
Create Path :
Current File : /var/www/html/rental/app/Http/Middleware/AuthenticateAdmin.php

<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Contracts\Auth\Guard;

class AuthenticateAdmin
{
    /**
     * The Guard implementation.
     *
     * @var Guard
     */
    protected $auth;

    /**
     * Create a new filter instance.
     *
     * @param  Guard  $auth
     * @return void
     */
    public function __construct(Guard $auth)
    {
        $this->auth = $auth;
    }

    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        if ($this->auth->guest()) {
            if ($request->ajax()) {
                return response('Unauthorized.', 401);
            } else {
                return redirect()->guest('login');//the non-logged-in user is redirected to the /login url
            }
        }
		else
		{	
			if($this->auth->user()->id_role >= 5)
			{
				return redirect('my-account');//redirect clients to their account and protect admin section
			}
		}
		
        return $next($request);
    }
}

Zerion Mini Shell 1.0