<?php
namespace WpBookingHotelFrontend\app\models;
defined('_WPBOOKINGHOTEL_EXEC') or die;

use WpBookingHotel\Factory;
use WpBookingHotel\Mvc\Model\ModelForm;
use WpBookingHotel\Form\Form;
use WpBookingHotel\Mvc\Model\ModelList;
use WpBookingHotel\Registry\Registry;
class CategoriesModel extends ModelList
{
    /**
     * @var string
     */
    public $context = "categories";
    /**
     * @var string
     */
    public $table_name = "category";
    public function getList()
    {
        $list = parent::getList(); // TODO: Change the autogenerated stub
        $query = $this->db->getQuery(true);
        foreach ($list as &$item) {
            $query->clear()
                ->select('service.*')
                ->from($this->getTableName('service') . ' AS service')
                ->where('service.category_id=' . (int)$item->id)
                ->where('service.published=1')
            ;
            $item->list_service = $this->_db->setQuery($query)->loadObjectList();
        }
        return $list;
    }
}
