Laravel - Localhost重定向了你太多次了

时间:2016-06-17 19:23:45

标签: php laravel laravel-4

我们差不多一年前开发了一个应用程序,在这里我遇到了一个问题。 登录后,Chrome说:The localhost page isn’t working, localhost redirected you too many times.。 问题在于控制器上的这段代码,当我删除它时,它工作正常。我无法弄清楚这有什么问题。

if(Auth::check()){
        $usertype=usertype::where('uid','=',Auth::user()->id)->first();
        if(isset($usertype)){
        if($usertype->type==1){
            $shopcatagory=shopcatagory::where('sid','=',Auth::user()->id)->first();
            $shopsubcatagory=shopsubcatagory::where('sid','=',Auth::user()->id)->first();
            $shopphone=shopphone::where('sid','=',Auth::user()->id)->first();
            $shopaddress=shopaddress::where('sid','=',Auth::user()->id)->first();
            $shopplace=shopplace::where('sid','=',Auth::user()->id)->first();
            if(!isset($shopaddress) || !isset($shopcatagory) || !isset($shopsubcatagory) || !isset($shopphone) || !isset($shopplace)){
                return Redirect::action('HomeController@accountinfo',Auth::user()->id);
            }
        }

        else if($usertype->type==3){
            $shopphone=shopphone::where('sid','=',Auth::user()->id)->first();
            $shopaddress=shopaddress::where('sid','=',Auth::user()->id)->first();
            $shopplace=shopplace::where('sid','=',Auth::user()->id)->first();
            if(!isset($shopaddress) || !isset($shopphone) || !isset($shopplace)){
                return Redirect::action('HomeController@accountinfo',Auth::user()->id);
            }
        }

        else if($usertype->type == 2){
            $userinterests=userinterests::where('uid','=',Auth::user()->id)->first();
            if(!isset($userinterests)){
                return Redirect::action('HomeController@interests');
            }
        }

        }
    }

1 个答案:

答案 0 :(得分:1)

在这个大Auth::check块中,您可能会将两个不同的路由重定向到:accountinfointerests

因此,如果您陷入无限循环,那么听起来这些代码正在这些路径的一个(或两个)上运行!

向下追踪,确保这两条路线都没有包含此重定向的Auth::check代码。