@Sinnbeck
i tried hasManyThrough like below,
return $roomdata = Room::with(['roomslots' => function ($q) use ($bookingdate, $currenttime) {
$q->when($bookingdate == todaydate(),function($qu) use ($currenttime) {
$qu->where('from_time','>',$currenttime);
});
}])->withCount(['bookedslots' => function ($q) use($bookingdate) {
$q->where('student_schedule_date',$bookingdate)
->whereIn('attended_status',['None','Present']);
}])
->where('room_code', $request->room)
->where('active_status', 1)
->first();
Room.php
public function bookedslots()
{
return $this->hasManyThrough(
BookedSlot::class,
RoomSlot::class,
'room_id',
'room_slot_id',
);
}
But above query return count including all slots but i need it in slot level
right now i am getting response like below,
bookedslots_count: 1,
seating_capacity: 2,
subcenterroomslots: [ {
0: {id: 7, sub_center_room_id: 5, from_time: "09:00:00",…}
1: {id: 8, sub_center_room_id: 5, from_time: "13:00:00",…}
2: {id: 10, sub_center_room_id: 5, from_time: "18:00:00",…}
}]
i want to alter like below,
seating_capacity: 2,
subcenterroomslots: [ {
0: {id: 7, sub_center_room_id: 5, from_time: "09:00:00",bookedslots_count: 1,}
1: {id: 8, sub_center_room_id: 5, from_time: "13:00:00",bookedslots_count: 0}
2: {id: 10, sub_center_room_id: 5, from_time: "18:00:00",bookedslots_count: 0}
}]