首页 文章

属性redirectPath和redirectTo设置位置? Laravel trait AuthenticatesAndRegistersUsers

提问于
浏览
3

在Laravel 5.0中,特征AuthenticatesAndRegistersUsers中的redirectPath方法检查属性redirectPath或redirectTo是否存在 . 如果是,则将用户重定向到该路径 .

问题是,它在哪里设定?据我所知,它设置为页面用户在重定向到/ auth / login页面之前尝试加载 . 但是,我无法弄清楚这是设置在哪里 .

public function redirectPath()
{
    if (property_exists($this, 'redirectPath'))
    {
        return $this->redirectPath;
    }

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

2 回答

  • 6

    默认情况下's not set at all!! That'为什么函数需要使用 property_exists() 来检查它 . 您可以使用 use AuthenticatesAndRegistersUsers 将其设置为导入特征的任何位置 .

    在默认的Laravel安装中,它将是 AuthController

    class AuthController extends Controller {
    
        use AuthenticatesAndRegistersUsers;
    
        protected $redirectTo = '/foo/bar';
    
        // ...
    }
    
  • 0

    特质:

    照亮\基金会\验证\ RedirectsUsers.php

相关问题