Eloquent

Download laravel eBook

Introduction

The Eloquent is an ORM (Object Relational Model) included with the Laravel. It implements the active record pattern and is used to interact with relational databases.

Remarks

Table naming

The convention is to use pluralised “snake_case” for table names and singular “StudlyCase” for model names. For example:

  • A cats table would have a Cat model
  • A jungle_cats table would have a JungleCat model
  • A users table would have a User model
  • A people table would have a Person model

Eloquent will automatically try to bind your model with a table that has the plural of the name of the model, as stated above.

You can, however, specify a table name to override the default convention.

class User extends Model
{ 
    protected $table = 'customers';
}

Related Examples

Stats

1406 Contributors: 51
Friday, June 16, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook