我正在尝试通过以下方式将 pageTitle 变量传递给 Laravel 5.3 中的密码重置模板 (/resources/views/auth/passwords/reset.blade.php):
return view('auth.passwords.reset')
->with('pageTitle', 'Change title')
->with(['token' => $token, 'email' => $request->email]);
这是在 ResetsPasswords
特性内的 showResetForm
方法中进行的 - 它不起作用。 Google 没有得出任何有用的结果。我试过删除该行:
->with(['token' => $token, 'email' => $request->email]);
但是还是不行。我也试过了
$pageTitle = 'Change me';
return view('auth.passwords.reset', compact('pageTitle'));
但它不起作用。另外,我已经意识到 ResetsPassword
特征是在 vendor 文件夹中找到的,所以更改那里的代码是个坏主意,你如何建议我改为这样做?我可以在某处覆盖 showResetForm
方法吗? - 我发现对于注册特性,我可以将 showRegistrationForm
放在 RegistrationController
中,并将我想要的任何变量传递到那里的 View ;然而,这不适用于 ResetPasswordController
编辑:
这是 ResetsPasswords
特征的整个方法,按照要求:
/**
* Display the password reset view for the given token.
*
* If no token is present, display the link request form.
*
* @param \Illuminate\Http\Request $request
* @param string|null $token
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function showResetForm(Request $request, $token = null)
{
return view('auth.passwords.reset')->with(['token' => $token, 'email' => $request->email]);
}
最佳答案
尝试使用compact
return view('auth.passwords.reset', compact('token', 'email', etc..));
关于php - Laravel 5.3 将数据传递到密码重置模板失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41331213/