PHP Error: Class 'Illuminate/Foundation/Auth/Admin' [Laravel 8]

2.2k Views Asked by At

I have issues with the php error when I tried to insert data for admin using the tinker. I'm creating a multi authentication user which is one for user and one for admin.

PHP Error: Class 'Illuminate/Foundation/Auth/Admin' not found in c:/S/htdocs/i-V/app/Models/Admin.php on line 13

How do I resolve that error?

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',
    ];
} 

enter image description here

I have tried to remove the composer.lock file then install it again also I have done this.

composer dump-autoload
composer install --no-scripts
composer update
1

There are 1 best solutions below

2
On BEST ANSWER

Change this

use Illuminate\Foundation\Auth\Admin as Authenticatable;

to

use Illuminate\Foundation\Auth\User as Authenticatable;

as Illuminate\Foundation\Auth\User it is core code from laravel core and it don't have Admin class