<?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 StatesModel extends ModelList
{
    /**
     * @var string
     */
    public $context = "states";
    /**
     * @var string
     */
    public $table_name = "state";
    public function getListQuery()
    {
        $query = $this->_db->getQuery(true);
        $query->clear()
            ->select('a.*')
            ->from($this->getTableName() . ' AS a')
            ->leftJoin($this->getTableName('country') . ' AS country ON country.id =a.country_id')
            ->select('country.countryname  AS country_name')
            ->order('a.id DESC')

        ;
        return $query;
    }

    public function getList()
    {
        $db=Factory::getDBO();
        $query=$this->getListQuery();

        return $db->setQuery($query)->loadObjectList();
    }

}
