Defining Models: Eloquent Model Conventions
Eloquent Model Conventions
Table Names
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Flight extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'my_flights';
} By convention, the "snake case", plural name of the class will be used as the table name unless another name is explicitly specified.
Primary Keys
Is an incrementing integer value, which means that by default the primary key will be cast to an int automatically.
Timestamps
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Flight extends Model
{
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
}
Semantic portal