fix articles datatables, enhance statistics
This commit is contained in:
52
app/Repositories/Shop/OrderStatistics.php
Normal file
52
app/Repositories/Shop/OrderStatistics.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Core\DateStats;
|
||||
|
||||
class OrderStatistics
|
||||
{
|
||||
use DateStats;
|
||||
|
||||
public static function countPreparationLess2Days()
|
||||
{
|
||||
return Order::ofLastHours(48)->Preparation()->count();
|
||||
}
|
||||
|
||||
public static function countPreparationMore2Days()
|
||||
{
|
||||
$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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user