Laravel 5.2 auth change 'users' table

Draity picture Draity · Jan 7, 2016 · Viewed 7.5k times · Source

I used the new feature in Laravel:

 php artisan make:auth

But when I register it will use the database table users by default, but I want to change that to an other table. And by default it uses updated_at and created_at in that table, I want to remove that too.

Auth/AuthController

protected function create(array $data)
{
    return User::create([
        'voornaam' => $data['voornaam'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);
}

app\User

protected $fillable = [
    'voornaam', 'email', 'password',
];

This are the things I thought would change it, but they didn't. I hope somebody can tell me some more about this issue.

Answer

Marcin Nabiałek picture Marcin Nabiałek · Jan 7, 2016

To change table name go to app/User.php and set property $table to custom one for example:

$table = 'new_table';

You should also change default migration. Go to: /database/migrations/2014_10_12_000000_create_users_table.php file and change users here for the same name. To remove timestamps you can remove line:

$table->timestamps();

however if I were you I would reconsider removing those timestamps