Let's say I have two models 'Car' and 'Domestic' that use the same table named 'cars'. As example:
cars id | brand | type 0 | bmw | foreign 1 | audi | domestic 2 | ford | domestic
The 'Car' model uses the whole 'cars' table as it is. But when I call the 'Domestic' model then only the rows that have the 'type' column set to 'domestic' will be used and affected. So that when I do:
$cars = Car::all(); // returns all cars $domestics = Domestic::all(); // returns domestic cars Domestic::create(['brand'=>'fiat']); // creates a car with domestic type
We can customize the table name for the model with
protected $table = 'cars'. Is there a way to restrain the custom table?