add new metrics, graph metrics, prepare basket to storage

This commit is contained in:
ludo
2024-01-29 23:44:49 +01:00
parent 9fcc81f4d9
commit 53ad10eefa
12 changed files with 219 additions and 214 deletions

View File

@@ -4,38 +4,71 @@ namespace App\Repositories\Shop;
use App\Models\Shop\Order;
use App\Repositories\Core\DateStats;
use Carbon\Carbon;
use App\Traits\Model\Basic;
class OrderMetrics
{
use DateStats;
use Basic, DateStats;
public static function countInPreparationLess24H()
public static function getTotalDaily()
{
$start = Carbon::now()->subHours(24);
$end = Carbon::now();
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
return self::sumDaily('total_taxed');
}
public static function countInPreparationLess48H()
public static function getTotalMonthly()
{
$start = Carbon::now()->subHours(48);
$end = Carbon::now();
return Order::preparation()->byPeriod($start, $end, 'updated_at')->count();
return self::sumMonthly('total_taxed');
}
public static function countInPreparationMore48H()
public static function countPreparationLess24h()
{
$start = Carbon::now()->subHours(48);
$date = now()->subHours(24);
return Order::preparation()->where('updated_at', '>', $start)->count();
return Order::Preparation()->where('updated_at', '>', $date)->count();
}
public static function getTotalByPeriod($start, $end)
public static function countPreparationLess48h()
{
return self::sumByPeriod($start, $end, 'total_shipped');
$date = now()->subHours(48);
return Order::Preparation()->where('updated_at', '>', $date)->count();
}
public static function countPreparationMore48h()
{
$date = now()->subHours(48);
return Order::Preparation()->where('updated_at', '<', $date)->count();
}
public static function countOfToday()
{
return Order::ofToday()->count();
}
public static function countOfLastWeek()
{
return Order::ofLastWeek()->count();
}
public static function countOfLastMonth()
{
return Order::ofLastMonth()->count();
}
public static function getTotalOfToday()
{
return Order::ofToday()->sum('total_taxed');
}
public static function getTotalOfLastWeek()
{
return Order::ofLastWeek()->sum('total_taxed');
}
public static function getTotalOfLastMonth()
{
return Order::ofLastMonth()->sum('total_taxed');
}
public static function getModel()