https://laravel.com/docs/5.6/queries#joins
$result = Rest::leftJoin('bookings', 'rest_id', '=', 'id')->whereNull('rest_id')->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can i write this Join Query with Eloquent Laravel $result = DB::select("SELECT rests.* FROM rests LEFT JOIN bookings ON bookings.rest_id = rests.id Where bookings.rest_id IS NULL ");
It worked as next $un_booked_rests = DB::table('rests')->LeftJoin('bookings','rests.id' ,'=' ,'bookings.rest_id') ->select('rests.*') ->WhereNull('bookings.rest_id') ->get();
Please or to participate in this conversation.