acharmat
acharmat

Reputation: 125

Rename Users Table in Laravel 5.2

The default table name for Accounts is "users" and I'd like to change it to a different name...

I found this post: http://laraveldaily.com/how-to-rename-users-db-table-in-default-laravel-auth/

But it doesn't seem to work for me....

QueryException in Connection.php line 669:
SQLSTATE[42S02]: Base table or view not found: 1146 La table 'test2.users' n'existe pas (SQL: insert into `users` (`name`, `email`, `password`, `updated_at`, `created_at`) values (Charmat Abderaouf, [email protected], y$iOL7NImrKCdEWvuTNGhA6.u4k55lk9mM.GUSUrxNzGs5cYl3P5.h6, 2016-03-13 21:58:09, 2016-03-13 21:58:09))

Upvotes: 1

Views: 595

Answers (2)

user320487
user320487

Reputation:

As @Icehawg mentioned, change the $table variable to your desired table name. If you have an existing database, you'll likely want to create a migration for altering your table schema. See here: https://laravel.com/docs/5.2/migrations#renaming-and-dropping-tables

Upvotes: 0

Landjea
Landjea

Reputation: 384

In your users model, add a variable called "table" and use whatever table name you like.

protected $table = 'your_table_name';

Upvotes: 1

Related Questions