I am trying to do a left join using eloquent on a one to many relationship. I would only like to get the row with the highest value in the sort_order column.
So far my query looks like this:
Package::select('packages.*')
->leftJoin('package_routes', 'package_routes.package_id', '=', 'packages.id')
->leftJoin('package_route_items', function($join){
$join->on('package_route_items.package_route_id', '=', 'package_routes.id')
->where(???);
})->...//do more stuff to query here
I'm stuck on the where clause, if I should even be using a where at all.
sort_ordercolumn