Add new version in repository

This commit is contained in:
Ludovic CANDELLIER
2021-07-25 23:19:27 +02:00
parent d174fe1c81
commit 0d421226fa
608 changed files with 12235 additions and 7513 deletions

View File

@@ -6,32 +6,17 @@ class Stat
{
public static $is_debug = false;
public static $force_output = true;
private static $_instance;
private function __construct()
public static function getNewByPeriod($model, $start, $end)
{
return $model->whereBetween('created_at', [$start, $end])->count();
}
public static function getInstance()
public static function getTotalAtDate($model, $end)
{
if (is_null(self::$_instance)) {
self::$_instance = new self();
}
return self::$_instance;
return $model->where('created_at', '<', $end)->count();
}
public static function push($range, $var)
{
$tab = (is_array($var)) ? $var : array();
foreach ($range as $item) {
$begin = date_timestamp_get($item['begin']);
$end = date_timestamp_get($item['end']);
$tab[] = ['begin' => $begin, 'end' => $end, 'count' => $item['count']];
}
return $tab;
}
/*
fonctions de rendus
*/
@@ -148,16 +133,16 @@ class Stat
$end = Carbon::now();
$begin = Carbon::now()->subMonth(1);
switch ($period) {
case 'days':
$periods = DateRange::getPeriodsbyDay($begin, $end);
break;
case 'months':
$periods = DateRange::getPeriodsbyMonth($begin, $end);
break;
case 'weeks':
$periods = DateRange::getPeriodsbyWeek($begin, $end);
break;
default:
case 'days':
$periods = DateRange::getPeriodsbyDay($begin, $end);
break;
case 'months':
$periods = DateRange::getPeriodsbyMonth($begin, $end);
break;
case 'weeks':
$periods = DateRange::getPeriodsbyWeek($begin, $end);
break;
default:
}
return ($periods);
}