Laravel - Database, Table and Column Naming Conventions?

前端 未结 4 1347
生来不讨喜
生来不讨喜 2020-12-03 05:14

I\'m using laravel eloquent data objects to access my data, what is the best way to name my tables, columns, foreign/primary keys etc?

I found, there are lots of nam

4条回答
  •  感动是毒
    2020-12-03 05:40

    I don't agree in general with these examples you both have shown right on here.

    It is clean if you take a look at the official Laravel documentation, especially in the Eloquent's relationship session (http://laravel.com/docs/4.2/eloquent#relationships).

    Table names should be in plural, i.e. 'users' table for User model.

    And column names don't need to be in Camel Case, but Snake Case. See it is already answered: Database/model field-name convention in Laravel?

    It is too usual you can see it is like the RedBeanORM: the Snake Case for columns, even if you try other one. And it is adviced to avoid repeating the table names with column ones due to the method you can call from the Model object to access their relationships.

提交回复
热议问题