douchuang1861 2016-12-26 12:21
浏览 49
已采纳

Laravel 5.3将数据传递给密码重置模板失败

I am trying to pass a pageTitle variable to the password reset template (/resources/views/auth/passwords/reset.blade.php) in Laravel 5.3 in the following way:

return view('auth.passwords.reset')
    ->with('pageTitle', 'Change title')
    ->with(['token' => $token, 'email' => $request->email]);

this goes in the showResetForm method inside ResetsPasswords trait - and it doesn't work. Google doesn't come up with any helpful results. I've tried removing the line:

    ->with(['token' => $token, 'email' => $request->email]);

but it still doesn't work. I've also tried

$pageTitle = 'Change me';
return view('auth.passwords.reset', compact('pageTitle'));

but it doesn't work. Also, I've realized that the ResetsPassword trait is found in the vendor folder so it's a bad idea to change the code there, how do you suggest I do this instead? Can I overwrite the showResetForm method somewhere? - I found that for the registration trait I can put the showRegistrationForm in the RegistrationController and pass whatever variables I want to the view there; however that doesn't work for the ResetPasswordController

EDIT:

Here is the whole method from the ResetsPasswords trait, as requested:

/**
 * 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]);
}
  • 写回答

3条回答 默认 最新

  • douxu4610 2016-12-26 17:43
    关注

    The problem was I was editing the wrong trait, I need to edit the SendsPasswordResetEmails trait and not the ResetsPassword.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现