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.
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
DO NOT FORGET TO CHANGE VALIDATION IN REGISTERCONTOLLER.PHP AS WELL.
from
'email' => 'required|email|max:255|unique:users',
to
'email' => 'required|email|max:255|unique:company',
By default model take its class name as table name !
I define a protected property at the top of App/User.php
protected $table = 'auth_users';
This tells laravel to use auth_users
table instead of default user
table.
and it works like charm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With