add graphs for stats

This commit is contained in:
ludo
2024-01-29 22:39:57 +01:00
parent 75107285e7
commit 9fcc81f4d9
7 changed files with 202 additions and 73 deletions

View File

@@ -30,24 +30,24 @@ class DateRange
public static function previousDay($nb = 1)
{
return [
'start' => Carbon::now()->subDay($nb)->startOfDay(),
'end' => Carbon::now()->subDay($nb)->endOfDay(),
'start' => Carbon::now()->subDays($nb)->startOfDay(),
'end' => Carbon::now()->subDays($nb)->endOfDay(),
];
}
public static function previousWeek($nb = 1)
{
return [
'start' => Carbon::now()->subWeek($nb)->startOfWeek(),
'end' => Carbon::now()->subWeek($nb)->endOfWeek(),
'start' => Carbon::now()->subWeeks($nb)->startOfWeek(),
'end' => Carbon::now()->subWeeks($nb)->endOfWeek(),
];
}
public static function previousMonth($nb = 1)
{
return [
'start' => Carbon::now()->subMonth($nb)->startOfMonth(),
'end' => Carbon::now()->subMonth($nb)->endOfMonth(),
'start' => Carbon::now()->subMonths($nb)->startOfMonth(),
'end' => Carbon::now()->subMonths($nb)->endOfMonth(),
];
}
@@ -79,7 +79,7 @@ class DateRange
public static function getPeriodsLastMonth($nb = 1, $withActual = true)
{
$end = $withActual ? Carbon::now()->endOfMonth() : self::lastMonth();
$begin = $nb === 1 ? $end->copy()->startOfMonth() : $end->copy()->startOfMonth()->subMonth($nb - 1);
$begin = $nb === 1 ? $end->copy()->startOfMonth() : $end->copy()->startOfMonth()->subMonths($nb - 1);
return self::getPeriodsByMonth($begin, $end);
}
@@ -108,7 +108,7 @@ class DateRange
public static function getPeriodsLastWeek($nb = 1, $withActual = true)
{
$end = $withActual ? Carbon::now()->endOfWeek() : self::lastWeek();
$begin = $end->copy()->subWeek($nb);
$begin = $end->copy()->subWeeks($nb);
return static::getPeriodsByWeek($begin, $end);
}
@@ -116,7 +116,7 @@ class DateRange
public static function getPeriodsLastDay($nb = 1, $withActual = true)
{
$end = $withActual ? Carbon::now()->endOfDay() : static::lastDay();
$begin = $end->copy()->subDay($nb);
$begin = $end->copy()->subDays($nb);
return static::getPeriodsByDay($begin, $end);
}
@@ -153,7 +153,7 @@ class DateRange
$date = Carbon::now()->startOfQuarter();
break;
case 4:
$date = Carbon::now()->subMonth(3)->startOfQuarter();
$date = Carbon::now()->subMonths(3)->startOfQuarter();
break;
default:
return false;
@@ -169,17 +169,17 @@ class DateRange
public static function lastMonth()
{
return Carbon::now()->subMonth()->startOfMonth();
return Carbon::now()->subMonths()->startOfMonth();
}
public static function lastWeek()
{
return Carbon::now()->subWeek()->startOfWeek();
return Carbon::now()->subWeeks()->startOfWeek();
}
public static function lastDay()
{
return Carbon::now()->subDay()->startOfDay();
return Carbon::now()->subDays()->startOfDay();
}
public static function getPeriodsByMonth($begin, $end, $interval = 1)