Laravel model's default table name
Note that we did not tell Eloquent which table to use for our Flight model. By convention, the "snake case", plural name of the class will be used as the table name unless another name is explicitly specified. So, in this case, Eloquent will assume the Flight model stores records in the flights table. You may specify a custom table by defining a table property on your model:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ModelName extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'my_flights';
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class ModelName extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'my_flights';
}
Post a Comment