I'm trying to check if the URL entered is the same as the authenticated users slug in the database. So if a user goes to example.com/user/bob-smith and it is in fact Bob Smith logged in, the application will let Bob continue because his slug in the User table is bob-smith.
I have the middleware registered but when I do
public function handle($request, Closure $next)
{
if($id != Auth::user()->slug){
return 'This is not your page';
}
else{
return $next($request);
}
}
I get
Class 'App\Http\Middleware\Auth' not found
I'm not sure how to use this inside of middleware. Can any one help?