<?php
namespace Models;


/**
 * Class Statad
 * @param $f3 \Base
 * @package Models
 */
class Statad extends DB_Resource {

	protected
			$fieldConf = array(
			'date' => array(
					'type' => 'INT4'
			),
			'ad_id' => array(
					'belongs-to-one' => '\Models\Ad',
			),
			'uniques' => array(
					'type' => 'INT4',
					'default' => 0,
			),
			'impressions' => array(
					'type' => 'INT4',
					'default' => 0,
			),
			'clicks' => array(
					'type' => 'INT4',
					'default' => 0,
			),
			'browsers' => array(
					'type' => 'BLOB',
			),
			'hostnames' => array(
					'type' => 'BLOB'
			),
			'referers' => array(
					'type' => 'BLOB'
			),
			'devices' => array(
					'type' => 'BLOB'
			),
			'oss' => array(
					'type' => 'BLOB',
			),
			'geos' => array(
					'type' => 'BLOB',
			),
	),
			$table = 'stats_ads';


	/**
	 * @param null $value
	 * @return BrowserStat
	 */
	public function get_browsers($value = null) {
		if ($value == null) $value = json_encode(array());
		return (json_decode($value));
	}


	/**
	 * @param null $value
	 * @return HostnameStat
	 */
	public function get_hostnames($value = null) {
		if ($value == null) $value = json_encode(array());
		return (json_decode($value));
	}

	/**
	 * @param null $value
	 * @return RefererStat
	 */
	public function get_referers($value = null) {
		if ($value == null) $value = json_encode(array());
		return (json_decode($value));
	}

	/**
	 * @param null $value
	 * @return DeviceStat
	 */
	public function get_devices($value = null) {
		if ($value == null) $value = json_encode(array());
		return (json_decode($value));
	}

	/**
	 * @param null $value
	 * @return OsStat
	 */
	public function get_oss($value = null) {
		if ($value == null) $value = json_encode(array());
		return (json_decode($value));
	}


	/**
	 * @param null $value
	 * @return GeoStat
	 */
	public function get_geos($value = null) {
		if ($value == null) $value = json_encode(array());
		return (json_decode($value, true));
	}
}
