Answer the question
In order to leave comments, you need to log in
Convert mysql query to laravel?
there is a mysql query
SELECT *
FROM `rooms`
WHERE `hotel_id` = $hotel_id
WHERE `people` = $people
WHERE `id` NOT IN (
SELECT `room_id`
FROM `orders`
WHERE `hotel_id` = $hotel_id
WHERE `date_from` < $date_to AND `date_to` > $date_from
пробую так, но какой-то бред
$rooms = DB::table('rooms')
->where('hotel_id','=', $request->hotel_id)
->where('people','=', $request->people)
->whereNotIn('id',DB::raw('SELECT `room_id`
FROM `orders`
WHERE `hotel_id` = '.$request->hotel_id.'
WHERE `date_from` < '.$to.' AND `date_to` > '.$from.''))
->orderBy('rooms.id', 'asc')->get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question