laravel Auth-使用附加数据登录后重定向



我正在考虑如何在登录后使用额外的数据集合进行重定向。我可以用一个集合来完成:

///trait AuthenticatesUsers in Auth/LoginController

protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
$products = Product::all();
return $this->authenticated($request, $this->guard()->user())
? : redirect()->intended($this->redirectPath())->with('pr', $products);
}

如何使用多个集合?

您可以随意多次链接with方法:

///trait AuthenticatesUsers in Auth/LoginController

protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
$products = Product::all();
$foo = Foo::all();
$bar = Bar::all();
return $this->authenticated($request, $this->guard()->user())
? : redirect()->intended($this->redirectPath())
->with('pr', $products)
->with('foo', $foo)
->with('bar', $bar);
}

最新更新