Laravel 5.4 密码重置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42784010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 5.4 Password Reset
提问by Dev.Wol
I have a Laravel 5.4 application and I have a view in my admin area that allows me to see all users.
我有一个 Laravel 5.4 应用程序,我的管理区域中有一个视图,允许我查看所有用户。
I want to create a function that allows me to click a button in the back end that automates the process of sending the default Laravel password reset functionality.
我想创建一个函数,允许我单击后端的按钮,该按钮自动发送默认 Laravel 密码重置功能的过程。
In my view I have the following:
在我看来,我有以下几点:
<table class="table table-hover">
<thead>
<th>#</th>
<th>Company</th>
<th>Name</th>
<th>Email Address</th>
<th>Action</th>
</thead>
<tbody>
@foreach(\App\User::all() as $c)
<tr>
<td>{{ $c->id }}</td>
<td>{{ $c->company->company_name }}</td>
<td>{{ $c->name }}</td>
<td>{{ $c->email }}</td>
<td><a href="/admin/user/{{ $c->id }}/password/reset">Password Reset</a></td>
</tr>
@endforeach
</tbody>
</table>
On the link click for resetting the password this currently via my routes hits the following function
在链接上点击重置密码,目前通过我的路线点击以下功能
public function passwordReset($id)
{
$user = User::FindOrFail($id);
Password::sendResetLink($user->email);
}
I'm not to familiar with Laravels default password reset functionality so I'm probably way off but I get the following error:
我不熟悉 Laravel 的默认密码重置功能,所以我可能已经离开了,但我收到以下错误:
Argument 1 passed to Illuminate\Auth\Passwords\PasswordBroker::sendResetLink() must be of the type array, string given,
传递给 Illuminate\Auth\Passwords\PasswordBroker::sendResetLink() 的参数 1 必须是数组类型,给定的字符串,
回答by Alexey Mezenin
You need to send an array with email
as key:
您需要使用email
as 键发送一个数组:
Password::sendResetLink(['email' => $user->email]);