Laravel 5.3 的用户模型中的 CanResetPassword

CanResetPassword in User Model for Laravel 5.3

我正在将我的应用程序从 Laravel 5.1 转换为 5.3。我不确定如何编辑我的用户模型中的 CanResetPassword 部分。

这是我laravel 5.1中的user.php文件:

namespace App\Models;

use Illuminate\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;

class User extends Model implements AuthenticatableContract, CanResetPasswordContract
{
    use Authenticatable, SoftDeletes, CanResetPassword;
    ...
}

现在,我不确定将其更改为 Laravel 5.3 时需要进行哪些编辑。

Laravel 5.3 用户模型是这样的:

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Database\Eloquent\SoftDeletes;

class User extends Authenticatable
{
    use Notifiable, SoftDeletes;
}

当我阅读documentation时,它说:

Before using the password reset features of Laravel, your user must use the Illuminate\Notifications\Notifiable trait.

已经存在了。

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.

我不明白,因为第一句说执行 CanResetPassword 合同,但第二句说它已经执行了。从上面的引用来看,这是否意味着我不需要包含 CanResetPassword 因为用户模型已经实现了这个接口?

谁能告诉我我需要对 Laravel 5.3 中的用户模型进行哪些编辑才能重置此密码?

正如文档所说,Authenticatable class (Illuminate\Foundation\Auth\User) 实际上包含 CanResetPassword 特性。它还包括 AuthenticatableAuthorizable 特征。

问题中的 Laravel 5.3 示例就是您所需要的。

希望对您有所帮助!