PHP 错误:类“Illuminate/Foundation/Auth/Admin”[Laravel 8]

lil*_*ily 1 php laravel tinker laravel-8

当我尝试使用修补程序插入管理员数据时,我遇到了 php 错误问题。我正在创建一个多重身份验证用户,其中一个用于用户,一个用于管理员。

PHP 错误:在第 13 行的 c:/S/htdocs/iV/app/Models/Admin.php 中找不到类“Illuminate/Foundation/Auth/Admin”

我该如何解决该错误?

Admin

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\Admin as Authenticatable;
use Illuminate\Notifications\Notifiable;
use App\Notifications\AdminResetPasswordNotification;


class Admin extends Authenticatable
{
    use HasFactory, Notifiable;

    protected $guard = 'admin';

    /**
     * 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',
    ];
} 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我尝试删除composer.lock文件,然后再次安装它,我也这样做了。

composer dump-autoload
composer install --no-scripts
composer update
Run Code Online (Sandbox Code Playgroud)

Kam*_*aul 5

改变这个

use Illuminate\Foundation\Auth\Admin as Authenticatable;

use Illuminate\Foundation\Auth\User as Authenticatable;

因为Illuminate\Foundation\Auth\User它是来自 laravel core 的核心代码,并且没有Admin