diff --git a/app/Services/StatisticService.php b/app/Services/StatisticService.php index 1db3b2e..8744bcc 100644 --- a/app/Services/StatisticService.php +++ b/app/Services/StatisticService.php @@ -187,7 +187,12 @@ class StatisticService */ public function storeRanking(array $input = [], int $top = 0): array { - $storeLedgers = Ledger::select(['store_id', DB::raw('SUM(sales) as sales'), DB::raw('SUM(expenditure) as expenditure')]) + $storeLedgers = Ledger::select([ + 'store_id', + DB::raw('SUM(sales) as sales'), + DB::raw('SUM(expenditure) as expenditure'), + DB::raw('SUM(new_customers) as new_customers'), + ]) ->filter(Arr::except($input, ['region']), LedgerFilter::class) ->groupBy('store_id'); @@ -211,6 +216,7 @@ class StatisticService 'id' => $store->id, 'title' => $store->title, ], + 'new_customers' => $store->new_customers ?: 0, 'sales' => trim_zeros($store->sales ?: 0), 'expenditure' => trim_zeros($store->expenditure ?: 0), ];