我正在将我的应用程序从 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;
}
当我阅读文档时,它说:
在使用 Laravel 的密码重置功能之前,您的用户必须 使用 Illuminate\Notifications\Notifying 特征。
已经存在了。
首先,验证您的 App\User 模型是否实现了 Illuminate\Contracts\Auth\CanResetPassword 合约。当然, 框架中包含的 App\User 模型已经实现了这一点 接口,并使用 Illuminate\Auth\Passwords\CanResetPassword 特征包括实现接口所需的方法。
我不明白,因为第一句话说要执行
CanResetPassword
合同,但第二句话说它已经执行了。从上面的引用来看,这是否意味着我不需要包含 CanResetPassword
,因为用户模型已经实现了这个接口?
有人可以告诉我需要对 Laravel 5.3 中的用户模型进行哪些编辑才能重置密码吗?
正如文档所说,
Authenticatable
类(Illuminate\Foundation\Auth\User
)实际上包含CanResetPassword
特征。它还包括 Authenticatable
和 Authorizable
特征。
您问题中的 Laravel
5.3
示例就是您所需要的。