If I do this,
Booking::query()->with('vehicle')
Laravel generates two queries:
select * from `bookings`
select * from `vehicles` where `vehicles`.`id` in (?, ?, ?, ?, ?, ?, ?, ?)
Can I tell Laravel to do a LEFT JOIN
instead so that I can do an orderBy
on vehicles.name
? Each booking only has one vehicle, so it wouldn't generate any extra records.
I'm aware that I can do DB::table('booking')->leftJoin
instead, but then it doesn't populate my models.