首页 > 解决方案 > Laravel - BadMethodCallException 调用未定义的方法 App\User::getAuthIdentifierName()

问题描述

我知道这个问题已经被问过很多次了,但是给出的答案都没有帮助。部分原因是因为大多数答案都说要做已经完成的事情。每个页面都给出错误:“BadMethodCallException 调用未定义的方法 App\User::getAuthIdentifierName()”。

这就是发生的事情。身份验证运行良好。然后我做了一个新的迁移:

php artisan migrate:fresh --seed

之后,错误出现。

这是我的应用程序/用户模型代码:

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use jeremykenedy\LaravelRoles\Traits\HasRoleAndPermission;
use Illuminate\Database\Eloquent\SoftDeletes;

class User extends Authenticatable implements MustVerifyEmail
// class User extends Authenticatable
{
    use SoftDeletes;
    use Notifiable;
    use HasRoleAndPermission;

    protected $dates = ['deleted_at'];

    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];
}

我已经尝试运行php artisan ui vue --auth并输入“是”所有覆盖问题,但这没有用。

任何有关其他可能导致此问题的帮助将不胜感激。

编辑:仅供参考,我唯一更改为重新迁移的是几个种子文件。

标签: laravelauthentication

解决方案


推荐阅读