Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 在主页中进行登录验证后,如何重定向用户?_Laravel_Redirect_Routing_Laravel 5.3 - Fatal编程技术网

Laravel 在主页中进行登录验证后,如何重定向用户?

Laravel 在主页中进行登录验证后,如何重定向用户?,laravel,redirect,routing,laravel-5.3,Laravel,Redirect,Routing,Laravel 5.3,在LoginController.php中 我想将用户重定向到主页。但在验证用户身份后,它总是显示空白页 公共函数验证器($data,$request) { $email=$data['email']; $check=User::where('email','=',$email)->first(); //如果未找到,则表示我们需要注册用户 如果($check!=null){ //已通过身份验证。。。。。 $id=intval($check->id); Auth::loginUsingId($id

在LoginController.php中 我想将用户重定向到主页。但在验证用户身份后,它总是显示空白页

公共函数验证器($data,$request)
{
$email=$data['email'];
$check=User::where('email','=',$email)->first();
//如果未找到,则表示我们需要注册用户
如果($check!=null){
//已通过身份验证。。。。。
$id=intval($check->id);
Auth::loginUsingId($id,true);
//echo'setTimeout(function(){window.history.go(-1);},3000);';
//echo'location.href=“/”;
return redirect()->guest(路线('home');
}

更改
返回重定向()->来宾(路线('home');

 return redirect('home');

return redirect()->路由('home');

并确保您的
home.blade.php
中有一些数据,否则它将显示空白页。

您应该编写此代码

public function authenticater($data,$request)
    {
        $email=$data['email'];
        $check=User::where('email', '=',$email)->first();
        //if not found means we need to register the user

        if ($check != null) {
            // Authentication passed.....
            $id=intval($check->id);
            Auth::loginUsingId($id,true);
            //echo '<html><script>setTimeout(function(){ window.history.go(-1); }, 3000);</script></html>';
            //echo '<html><script>location.href="/";</script></html>';

             return redirect()->route('profile');

        }
公共函数验证器($data,$request)
{
$email=$data['email'];
$check=User::where('email','=',$email)->first();
//如果未找到,则表示我们需要注册用户
如果($check!=null){
//已通过身份验证。。。。。
$id=intval($check->id);
Auth::loginUsingId($id,true);
//echo'setTimeout(function(){window.history.go(-1);},3000);';
//echo'location.href=“/”;
return redirect()->route('profile');
}
这将解决您的问题

解决它, 我的错误是:我从控制器的另一个方法调用了authenticator()。因此,控件将转到调用方方法。

$this->authenticater($data,$request);
        return redirect('/home');
解决了

安威,我都试过了。还是谢谢你@Jahid26和@Iftikhar uddin:)

$this->authenticater($data,$request);
        return redirect('/home');