如何通过电子邮件在 Laravel 5.4 中重设密码

How to password reset in Laravel 5.4 by e-mail

如何在用户单击密码重置按钮时将密码重置 link 发送到用户电子邮件。

我有一个表格

<form action="/company/password/reset/" method="POST">
      {{ csrf_field() }}
      <div class="row">

        <div class="input-field col s12">

          <input placeholder="Enter your email" id="emails" type="email" class="validate" required name="email">
          <label for="emails">E-mail Address</label>
        </div>   
      </div>
      <p><button type="submit" method="post">SUBMIT</button></p>
    </form>

路线

Route::post('/password/company/reset/', 'PasswordResetController@company');

和控制器

public function company($email)
    {
        $company = $request->email;
    Password::sendResetLink(['email' => $company]);
    }

现在不行,这是正确的方法吗??

我在 laravel 5.4

中找不到任何有关重置密码的教程

我收到此错误:

User must implement CanResetPassword interface.

如果您的表单的操作是 /company/password/reset/,则路由应定义为

Route::post('/password/company/reset/','PasswordResetController@company');

可以在控制器中检索表单的输入,如下所示:

public function company(Request $request) {
    $email = $request->email;
    ...

documentation 明确表示:

To get started, verify that your App\User model implements the Illuminate\Contracts\Auth\CanResetPassword contract. Of course, the App\User model included with the framework already implements this interface, and uses the Illuminate\Auth\Passwords\CanResetPassword trait to include the methods needed to implement the interface.

由于您有一些自定义用户模型,您需要实施此合同才能使用 Password::sendResetLink