1

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
lily
  • 199
  • 2
  • 3
  • 14

1 Answers1

4

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

Kamlesh Paul
  • 11,778
  • 2
  • 20
  • 33
  • 1
    Oh I didn't know that!. Thank you for explaining it works. So even thought we are creating another level of authentication so we only need to use this `Illuminate\Foundation\Auth\User` right? Thank you. – lily Sep 12 '20 at 05:47
  • @lily please mark this as answer so other will not spend time on this – Kamlesh Paul Sep 12 '20 at 05:56