问题描述
当我尝试使用修补匠为管理员插入数据时,php错误出现问题。我正在创建一个多身份验证用户,一个用于用户,一个用于管理员。
PHP错误:在第13行的c:/S/htdocs/i-V/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',];
}
我尝试删除composer.lock文件,然后再次安装 我也是这样做的。
composer dump-autoload
composer install --no-scripts
composer update
解决方法
更改此
use Illuminate\Foundation\Auth\Admin as Authenticatable;
到
use Illuminate\Foundation\Auth\User as Authenticatable;
就像Illuminate\Foundation\Auth\User
一样,它是laravel核心的核心代码,没有Admin
类