Laravel 8 Auth Model Different

Viewed 172

I want to create a model for my project but i don't know what's the different between the original MVC style and laravel default auth model

there's a directory different too. The original MVC was in Model folder, while the defaulth auth is in controller folder. I don't know why make a model inside the Controller folder

This is the code that's work ( laravel default auth model ) source : https://www.5balloons.info/changing-authentication-table-laravel/

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;

class CustomUser extends Authenticatable
{
    use Notifiable;

    protected $table = 'customusers';

    protected $fillable = [
        'name','username','email','passcode','active'
    ];

    protected $hidden = [
        'passcode',
    ];
}

while this code is not work with error Class 'App\Models\Authenticatable' not found

i can create a work around to use the class, but i need to understand why

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class TestUser extends Authenticatable
{
    use HasFactory, Notifiable;

  protected $table = 'testuser';

  protected $fillable = [
     'username','password',
  ];

  protected $hidden = [
    'password',
  ];

  /*
  public funtion getAuthPassword()
  {
    return $this-> passcode;
  }
  */
}

0 Answers
Related