Level 5
Any solution on this?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have a tables like below,
rooms
id, roomname,capacity
1, Room1, 4
room_slots
id, room_id,from_slot, to_slot
1, 1, 9:00:00, 10:00:00
2, 1, 11:00:00 13:00:00
room_test_bookings
id, room_slot_id, booking_date,test_id
So here requirement is like below in booking page,
room_test_bookings .
if room_test_bookings has 4 or more entries for a selected room and for selected date then that time slot should be filter out.i tried code like below,
$roomdata = SubcenterRooms::with(['subcenterroomslots.offlineconvertedtestdetail' => function($q) use($convertbookdate,$gettestid){
$q->where('student_schedule_date',$convertbookdate)
->where('test_id',$gettestid);
}])->where('room_code',$request->room)->where('active_status',1)->first();
SubcenterRooms.php (Model) (table name: rooms)
public function subcenterroomslots()
{
return $this->hasMany('App\RoomTimeSlots','sub_center_room_id','id')->where('active_status',1);
}
RoomTimeSlots.php (Model) (table name: room_slots)
public function offlineconvertedtestdetail()
{
return $this->hasMany('App\OfflineConvertedTest','room_slot_id','id')->where('attended_status','=','None');
}
Please help me with this how to write a condition inside the query to filter out.
Please or to participate in this conversation.