<?php
namespace WpBookingHotelFrontend\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;
use WpBookingHotelAdmin\app\helpers\AdminHelper;

class CurrencyModel extends ModelForm
{
    /**
     * @var string
     */
    public $context = "currency";
    /**
     * @var string
     */
    public $table_name = "currency";
    public function getItem($id = 0)
    {
        $db=$this->_db;
        return parent::getItem($id); // TODO: Change the autogenerated stub
    }

    public function format_currency($based = "USD"){
        $db=$this->_db;
        $query=$db->getQuery(true);
        $query->select('currency.symbol')
            ->from($this->getTableName('currency').' AS currency')
            ->where('currency.code='.$query->quote($based));
        $code = $this->_db->setQuery($query)->loadObject();
        return $code;
    }
}
