Eloquent ORM是否将CamelCase更改为下划线?

时间:2013-07-31 08:31:29

标签: laravel eloquent

我使用Eloquent在Laravel中收到错误:

SQLSTATE[42S02]: Base table or view not found: 1146 Table 
'task_manager.rel_developers_projects' doesn't exist (SQL: insert into 
`rel_developers_projects` (`project_id`, `developer_id`, `updated_at`, `created_at`) 
values (?, ?, ?, ?)) (Bindings: array ( 0 => '1', 1 => '1', 2 => '2013-07-31 08:23:35', 3 
=> '2013-07-31 08:23:35', ))

但是,该模型称为RelDevelopersProject,该表称为RelDevelopersProjects。

Eloquent是否尝试将CamelCased名称转换为下划线?

2 个答案:

答案 0 :(得分:2)

请勿将驼峰用例用于表名。

如果您需要,请尝试:

class RelDevelopersProject extends Eloquent {

    protected $table = 'RelDevelopersProjects';

}

请参阅Laravel文档中的eloquent

答案 1 :(得分:0)

是的,确实如此。 只需将表名定义为Model

中的属性即可
/**
 * The database table used by the model.
 *
 * @var string
 */
protected $table = 'RelDevelopersProject';