fix shipping

This commit is contained in:
Ludovic CANDELLIER
2023-07-16 17:54:44 +02:00
parent 1675745e2a
commit b8c31f6049
36 changed files with 640 additions and 897 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Repositories\Shop;
use App\Models\Shop\Order;
use App\Repositories\Core\DateStats;
use Carbon\Carbon;
class OrderMetrics
{
use DateStats;
public static function countInPreparationLess24H()
{
$start = Carbon::now()->subHours(24);
$end = Carbon::now();
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
}
public static function countInPreparationLess48H()
{
$start = Carbon::now()->subHours(48);
$end = Carbon::now();
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
}
public static function countInPreparationMore48H()
{
$start = Carbon::now()->subHours(48);
return Order::preparation()->where('updated_at', '>', $start)->count();
}
public static function getTotalByPeriod($start, $end)
{
return self::sumByPeriod($start, $end, 'total_shipped');
}
public static function getModel()
{
return Order::query();
}
}