简体   繁体   English

Laravel登录后重定向

[英]Laravel redirect back after login

How can I redirect back page after login? 如何在登录后重定向页面? in Laravel 5.2 在Laravel 5.2

AuthController AuthController

protected $redirectTo = '/';

RedirectUsers RedirectUsers

<?php

namespace Illuminate\Foundation\Auth;

trait RedirectsUsers
{
    /**
     * Get the post register / login redirect path.
     *
     * @return string
     */
    public function redirectPath()
    {
        if (property_exists($this, 'redirectPath')) {
            return $this->redirectPath;
        }

        return property_exists($this, 'redirectTo') ? $this->redirectTo : '/';
    }
}

You can do it by using either of these two options. 您可以使用这两个选项中的任何一个来完成。

  • return Redirect::back(); return Redirect :: back(); This will take the user back to the page from where he/she came. 这将使用户返回到他/她来的页面。
  • return redirect('enter your route here'); 返回重定向('在此处输入您的路线'); This will take the user to the view which you have defined with that particular route. 这将使用户进入您使用该特定路线定义的视图。

In your auth function which you've written in the controller. 在您在控制器中编写的auth功能中。 It'll be something like this: 它会是这样的:

 function xyz() {

  // your function code

  return Redirect::back();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM