The number of models should match the number of DB Tables (minus the pivot tables)
TorchSK said:
The number of models should match the number of DB Tables (minus the pivot tables)
I don't see any difference between using a model to do
Vehicle::where('ID', '=', '1')->first();
and just using this
DB::table('vehicles')->where('ID', '=', '1')->first();
All that models do is connect to databases? Are they more secure than DB::table?
Maybe not much difference for that query but to me, the model version looks cleaner
Vehicle::with('colour')->whereHas('price', function($query)
{
$query->where('amount', '<=', '10000');
})->where('active', 1)->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community