如何在主页登录认证后重定向用户?

How can i redirect user after login authentication in the home page?

In LoginController.php I want to redirect user to home page.but it always shows blank page after authenticating user.

    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()->guest(route('home'));

        }

return redirect()->guest(route('home'));改为

 return redirect('home');

return redirect()->route('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');

        }

这将解决您的问题

想通了, 我的错误是:我从 controller.So 的另一个方法调用了 authenticer(),控件将转到调用方方法。

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

已解决。 ..

无论如何,我尝试了所有 that.still 谢谢@Jahid26 和@Iftikhar uddin :)