<?php
namespace WpBookingHotelAdmin\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 CustomerModel extends ModelForm
{
    /**
     * @var string
     */
    public $context = "customer";
    /**
     * @var string
     */
    public $table_name = "customer";
    public function getItem($id = 0)
    {
        $customer =  parent::getItem($id); // TODO: Change the autogenerated stub
        $query= $this->_db->getQuery(true);
        if(!empty((array)$customer)) {
            $query->clear()
                ->select('country.countryname')
                ->from($this->getTableName('country').' AS country')
                ->where('country.phonecode='.(int)$customer->phonecode)
                ->where('country.countrycode='.$query->quote($customer->countrycode))
            ;
            $customer->country_name = $this->_db->setQuery($query)->loadResult();
        }

        return $customer;
    }
}
