在创建中间件之后,我在我的laravel应用程序中得到了多个重定向,肯定有一些地方我做错了,但是
我不知道在哪里。
public function handle($request, Closure $next)
{
$route = Route::currentRouteName();
if($route!= "dashboard" || $route != "verify.again")
{
if(! is_null($request->user()) && ! $request->user()->verified) {
return redirect()->route("verify.again");
}
elseif(!$request->user()->mobile){
return redirect()->route("verify.again");
}
else{
return $next($request);
}
}
return $next($request);
}
控制器
public function index(){
$user = Auth::user();
if(!$user->verified)
{
return view("dashboard.verification.index", ["verify"=>"email", ]);
}
elseif(!$user->mobile)
{
return view("dashboard.verification.index", ["verify"=>"mobile", ]);
}
return view("dashboard.usermaster");
}