Livewire密码重置组件调用sendResetLink参数类型错误如何解决?
问题原因
Password::sendResetLink() 方法要求第一个参数为键值对数组,你直接传入了Livewire组件的属性$this->email(字符串类型),所以触发了参数类型错误。
解决方案
把传入sendResetLink的参数改成包含email键的数组即可,和官方示例里$request->only('email')的返回结构保持一致,修改后代码如下:
$this->validate(); $status = Password::sendResetLink( ['email' => $this->email] ); return $status === Password::RESET_LINK_SENT ? back()->with(['status' => __($status)]) : back()->withErrors(['email' => __($status)]);
补充说明
官方示例中$request->only('email')的返回值本身就是['email' => '用户输入的邮箱']格式的数组,迁移到Livewire时对应调整参数结构即可正常运行。
内容的提问来源于stack exchange,提问作者SquareNet Media
相关产品推荐
相关产品推荐

