<?php
namespace WpBookingHotelAdminWooPanel\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 LocationsModel extends ModelList
{
    /**
     * @var string
     */
    public $context = "location";
    /**
     * @var string
     */
    public $table_name = "location";
    public function getList()
    {

        $db = Factory::getDBO();
        $query = $db->getQuery(true)
            ->select("location.*")
            ->from($this->getTableName('location').' AS location')
            ->leftJoin($this->getTableName('state').' AS state ON state.id=location.state_id')
            ->select('state.name AS state_name')
            ->leftJoin($this->getTableName('country'). ' AS country ON country.id=state.country_id')
            ->select('country.countryname AS country_name')
        ;

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

    }

}
