问题描述
Laravel 3/4中此表的正确表名称是什么?
结构
/>
image_projects(id,project_id,image,ext,size,created_at,updated_at,active)
image_projects
imageprojects
imageProjects
而且,我如何创建模型?
app / models / image_projects.php
app / models / imageprojects.php
app / models / imageProjects.php
app / models / image / projects.php
app / models / projects / image.php
只要你命名文件&类的名称以大写字母开头。
您可以使用以下任一选项:
表名: image_projects
文件名: / strong> ImageProject.php
类名: ImageProject
表名: imageprojects
文件名称: Imageproject.php
/ p>
类名: ImageProject
表名称: imageProjects
文件名: ImageProject.php
ImageProject
在这种情况下,您必须设置 $
记住:如果您不要以您命名表格的单一形式命名您的课程,您必须在您的模型中手动设置:
class ImageProjects extends Eloquent
{
public $ table ='image_projects';
}
What is the correctly table name of this table in Laravel 3/4?
Structure
image_projects (id, project_id, image, ext, size, created_at, updated_at, active)
image_projects
imageprojects
imageProjects
And, how I can create the Model?
app/models/image_projects.php
app/models/imageprojects.php
app/models/imageProjects.php
app/models/image/projects.php
app/models/projects/image.php
It makes no difference what you name your table, as long as you then name the file & class in singular form, with the class name starting with an uppercase letter.
You can use any of the following options:
Table name: image_projects
File name: ImageProject.php
Class name: ImageProject
Table name: imageprojects
File name: Imageproject.php
Class name: Imageproject
Table name: imageProjects
File name: ImageProject.php
Class name: ImageProject
In this case you'll have to set the $table
property yourself.
Remember: If you don't name your class in singular form of what you name your table, you'll have to manually set it in your model:
class ImageProjects extends Eloquent
{
public $table = 'image_projects';
}
这篇关于公约表名(带下划线)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!