<?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 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;
    }
}
