<?php

defined('HOSTCMS') || exit('HostCMS: access denied.');

/**
 * Shop_Tax_Model
 *
 * @package HostCMS
 * @subpackage Shop
 * @version 6.x
 * @copyright © 2005-2019, https://www.hostcms.ru
 */
class Shop_Tax_Model extends Core_Entity
{
	/**
	 * Belongs to relations
	 * @var array
	 */
	protected $_belongsTo = array(
		'user' => array()
	);

	/**
	 * Constructor.
	 * @param int $id entity ID
	 */
	public function __construct($id = NULL)
	{
		parent::__construct($id);

		if (is_null($id) && !$this->loaded())
		{
			$oUser = Core_Auth::getCurrentUser();
			$this->_preloadValues['user_id'] = is_null($oUser) ? 0 : $oUser->id;
		}
	}

	/**
	 * Switch tax_is_included flag
	 * @return self
	 */
	public function changeIncluded()
	{
		$this->tax_is_included = 1 - $this->tax_is_included;
		return $this->save();
	}
}