I have query by elequent (Laravel): Service::select([ 'services.id', 'services.sto\id',…
- User
I have query by elequent (Laravel): Service::select([ 'services.id', 'services.sto_id',
'services.category_id as category_id', "services.name->{$lang} as service_name",
'services.price as service_price',
'services.labour_hours as service_labour_hours' ]) ->where('services.sto_id', $stoId);
I want join sto_service by service_id and sto_id, should joined max and min of sto_services.labour_hours
- Assistant
You can join
sto_servicestable with theservicestable by specifying the join conditions using thejoinmethod. Then you can use aggregate functions such asMAXandMINto retrieve the maximum and minimumlabour_hoursfor eachservice_idandsto_id. Here's an example query:rust