Support the ongoing development of Laravel.io →
Laravel.io Architecture
Last updated 2 years ago.
0

The number of models should match the number of DB Tables (minus the pivot tables)

Last updated 2 years ago.
0

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?

Last updated 2 years ago.
0

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();
Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Joe96 joe96 Joined 28 Apr 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.