【问题标题】:Rename Users Table in Laravel 5.2在 Laravel 5.2 中重命名用户表
【发布时间】:2016-03-14 12:57:07
【问题描述】:

Accounts 的默认表名是“users”,我想将其更改为其他名称...

我发现了这个帖子: http://laraveldaily.com/how-to-rename-users-db-table-in-default-laravel-auth/

但它似乎对我不起作用......

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, rcherire@gmail.com, y$iOL7NImrKCdEWvuTNGhA6.u4k55lk9mM.GUSUrxNzGs5cYl3P5.h6, 2016-03-13 21:58:09, 2016-03-13 21:58:09))

【问题讨论】:

    标签: laravel authentication laravel-5


    【解决方案1】:

    在您的用户模型中,添加一个名为“table”的变量并使用您喜欢的任何表名称。

    protected $table = 'your_table_name';
    

    【讨论】:

    • 我的用户模型在哪里?在哪个目录下的哪个文件中?
    • Laravel 5 你可以在 app\http 文件夹中找到你的用户模型。
    【解决方案2】:

    正如@Icehawg 提到的,将 $table 变量更改为您想要的表名。如果您有一个现有的数据库,您可能希望创建一个迁移来更改您的表模式。见这里:https://laravel.com/docs/5.2/migrations#renaming-and-dropping-tables

    【讨论】:

      猜你喜欢
      • 2017-11-19
      • 2016-11-27
      • 2016-10-03
      • 2016-04-23
      • 1970-01-01
      • 2017-02-25
      • 2016-04-12
      • 1970-01-01
      • 2018-07-18
      相关资源
      最近更新 更多