I’m trying to change a Laravel's default table name from its model name and plural to the other custom name. From reading around I thought I had to just update that in the app/Model/User.php for example then am done. But unfortunately its not working. Here is what I tried by changing the users table to the web_registration table:
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens, HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
*@var string[]
**/
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'web_registration';
/**
* The attributes that should be hidden for serialization.
*
* @var array
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
But when I run the migrations I am still getting the users table instead of the web_registration table. Note that I have also run composer dump-autoload -o as suggested by other stack answers but still no any changes. Is there anywhere else where I need to change this?