3 months ago

Auth middleware error.

Posted 3 months ago by sanjayacloud

Hi Everyone,

I am trying to make auth middleware call "Admin" And it registered on http kernal. But when i add it into my controller in constructor. I got below error.

Error: "Class admin does not exist"

My constructor

public function __construct()

And below my middleware


namespace App\Http\Middleware;

use Closure;

class Admin
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
    public function handle($request, Closure $next)
        if(auth()->user()->role == 5){
            $response = $next($request);
            $response->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0')->header('Pragma', 'no-cache')->header('Expires', 'Sat, 26 Jul 1997 05:00:00 GMT');
            return $response;
        return redirect('/admin/login')->with('login-msg','You have not admin access');

Anyone can help me to resolve this error?

Please sign in or create an account to participate in this conversation.