I have created block with function getRooms(). This function make joinLeft query for two tables and return items collection.
Actually It’s not initiall room collection because It has group, sum and other countable field.
In the phtml template I render these collection and should check each item, call function.
For example:
<?php $rooms = $this->getRooms();
foreach ($rooms as $room) : ?>
<?php if ( $this->isAvailable($room) ) : ?>
<!-- some html here -->
isAvailable function work with $room values, thefore I feel It should be called like
$room->isAvailable();
instead of
$this->isAvailable($room)
In this case isAvailable() should be in Model. But what model? As I mentioned above my query is joining of two tables. So what model should be used? Maybe Magento has possibility to create model based on joining tables (instead of one table)?
The Collection object contains Models that you’re using. All the
joiningwork was done simply to add more data to your model (data that is required by your logic). To get the Model class simply use