我正在使用我自己的User模型类,它不是从Eloquent派生的 . 我使用数据库驱动程序进行身份验证,工作正常 .

但是,Auth :: user()返回GenericUser类型的类 . 有没有办法将自定义用户模型分配给Auth类?

我试过auth config ...

'users' => [
    'driver' => 'database',
    'table' => 'users',
    'model' => App\Models\User::class
],

但它不起作用 . 也许这个功能不存在 .

Edit:

我不想使用Active记录,我有一个Data Mapper包 . 我的用户模型看起来像这样......

<?php

class User extends Model
{
    use Notifiable, HasApiTokens, CanResetPassword;
    use Authenticatable, Authorizable;

    protected $attributes = [
        'id' => null, 'roleId' => null,
        'email' => null, 'phone' => null,
        'firstName' => null, 'lastName' => null,
        'password' => null, 'rememberToken' => null,
        'registrationLocation' => null,
        'data' => null,
        'verified' => 0,
        'createdAt' => null, 'updatedAt' => null,
    ];

    public function __construct(array $attributes = [])
    {
        $this->fill($attributes);
    }
}

模型从数据映射器包的类实体扩展而来 .