<?php
namespace TourOperatorProAdminWoopanel\app\models;
defined('_TOUROPERATOR_EXEC') or die;

use TourOperatorPro\Factory;
use TourOperatorPro\Mvc\Model\ModelForm;
use TourOperatorPro\Form\Form;
use TourOperatorPro\Mvc\Model\ModelList;
use TourOperatorPro\Registry\Registry;
class ActivitiesModel extends ModelList
{
    /**
     * @var string
     */
    public $context = "activities";
    /**
     * @var string
     */
    public $table_name = "activity";

    public function getList()
    {
        $list = parent::getList(); // TODO: Change the autogenerated stub
        $query = $this->db->getQuery(true);
        foreach ($list as &$item) {
            $query->clear()
                ->select('tour.*')
                ->from($this->getTableName('tour') . ' AS tour')
                ->where('tour.activity_id=' . (int)$item->id);
            $item->list_tour = $this->db->setQuery($query)->loadObjectList();
        }
        return $list;
    }
    public function getListQuery_activity_public()
    {
        $db = Factory::getDBO();
        $query = $this->db->getQuery(true);
        $query->select('activity.*')
            ->from($this->getTableName('activity') . ' AS activity')
            ->where('activity.published=1');
        return $query;
    }
    public function getList_activity_public()
    {
        $db=Factory::getDBO();
        $query=$this->getListQuery_activity_public();
        $limit_per_page=$this->get_limit_per_page();

        return $db->setQuery($query, $this->getStart(),$limit_per_page)->loadObjectList();
    }
}
