That's strange.
Can you show the controller for the room category component please ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have the following code on my Livewire Class (ReservationForm.php):
public $room_types;
public function mount() {
$this->room_types = RoomType::withCount(['rooms' => function ($query) {
$query->where('status', Room::STATUS_AVAILABLE);
}])->get();
}
Then, in my reservation-form.blade.php (Livewire Component) I passes the '$room_types' property to a regular blade component named 'room-category.blade.php' like this:
<x-room-category :roomTypes="$room_types" />
The problem I am having is that the 'rooms_count' attribute that should be added by the RoomType::withCount() eloquent method is being removed from the collection when I passed the '$room_types' property in the regular blade component (room-category.blade.php).
How can I fix this? T_T
I think perhaps when the livewire component re-renders, it repopulates the model but not the count property.
If the data does not need to be manipulated, load the roomtypes with count in the render method and not the mount method
Please or to participate in this conversation.