【问题标题】:required table for Laravel 5 AuthenticationLaravel 5 身份验证所需的表
【发布时间】:2015-07-04 06:07:20
【问题描述】:

我正在使用 Laravel 的身份验证功能,正如文档中所说,我的应用程序中应该有一个“用户”表,以便我可以使用此功能,但我得到了一个“用户”而不是“用户”表“ 桌子。 我更改了 User 模型的 $table 属性,还更改了我的 Auth 配置文件的 table 属性: '表' => '用户' 但在注册时仍然出现此错误: Connection.php 第 620 行中的 QueryException: SQLSTATE [42S02]:未找到基表或视图:1146 表 'project.users' 不存在(SQL:从users 中选择计数(*)作为聚合,其中email = sth@yahoo.com)

【问题讨论】:

  • 在您的User Model 中添加protected $table = 'user';

标签: laravel


【解决方案1】:

如果您为模型使用不同的表名,则需要定义它们。在你的情况下,你应该有

 protected $table = 'user';

像这样在你的用户模型中。

class User extends Authenticatable
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user';
}

【讨论】:

    猜你喜欢
    • 2015-04-25
    • 1970-01-01
    • 2015-08-21
    • 1970-01-01
    • 1970-01-01
    • 2016-03-19
    • 1970-01-01
    • 2015-06-08
    相关资源
    最近更新 更多