45 lines
1.1 KiB
PHP
45 lines
1.1 KiB
PHP
<?php
|
|
/*
|
|
Author: Riccardo Di Dato
|
|
Creation Date: 30/ago/2022
|
|
*/
|
|
|
|
|
|
class BannerStatsModel extends Model {
|
|
|
|
public function __construct($saveableObject = null){
|
|
parent::__construct($saveableObject);
|
|
}
|
|
|
|
public static function getCollectionName(){
|
|
return "banner_stats";
|
|
}
|
|
|
|
public static function new($bannerId, $day, $month, $year) {
|
|
$time = strtotime("$year-$month-$day CET");
|
|
return new static(
|
|
(object)[
|
|
'banner' => $bannerId,
|
|
'time' => new MongoDB\BSON\UTCDateTime( $time * 1000 ),
|
|
'y' => intval($year),
|
|
'm' => intval($month),
|
|
'd' => intval($day),
|
|
'views' => 0,
|
|
'clicks' => 0
|
|
]
|
|
);
|
|
}
|
|
public static function getFilter($bannerId, $day, $month, $year) {
|
|
$time = strtotime("$year-$month-$day CET");
|
|
return [
|
|
'banner' => $bannerId,
|
|
'time' => new MongoDB\BSON\UTCDateTime( $time * 1000 ),
|
|
'y' => intval($year),
|
|
'm' => intval($month),
|
|
'd' => intval($day)
|
|
];
|
|
}
|
|
|
|
}
|
|
|
|
?>
|