|
@@ -179,10 +179,34 @@ class AdminController extends Controller
|
|
$orders = $orders->orderBy('created_at', 'DESC');
|
|
$orders = $orders->orderBy('created_at', 'DESC');
|
|
|
|
|
|
$clonedOrdersQuery = clone $orders;
|
|
$clonedOrdersQuery = clone $orders;
|
|
|
|
+ $ordersSummary = $this->getOrdersQuickSummary($clonedOrdersQuery);
|
|
|
|
|
|
$orders = $orders->paginate(30);
|
|
$orders = $orders->paginate(30);
|
|
|
|
|
|
- return view('app.my-account.admin.orders.index', compact('orders', 'filters'));
|
|
|
|
|
|
+ return view('app.my-account.admin.orders.index', compact('orders', 'filters', 'ordersSummary'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private function getOrdersQuickSummary($storeOrderQuery){
|
|
|
|
+ $qryClone = clone $storeOrderQuery;
|
|
|
|
+
|
|
|
|
+ $records = $storeOrderQuery->get();
|
|
|
|
+ $ordersTotalAmount = 0;
|
|
|
|
+ foreach($records as $record){
|
|
|
|
+ $ordersTotalAmount = $ordersTotalAmount + $record->total();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $ids = $qryClone->pluck('id')->toArray();
|
|
|
|
+ $trxs = FinancialTransaction::whereIn('order_id', $ids)->where('charge_or_refund', 'CHARGE')->get();
|
|
|
|
+ $totalAmountCharged = 0;
|
|
|
|
+ foreach($trxs as $trx){
|
|
|
|
+ $totalAmountCharged = $totalAmountCharged + floatval($trx->amount);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $summary = [
|
|
|
|
+ 'orders_total_amount' => $ordersTotalAmount,
|
|
|
|
+ 'total_amount_charged' => $totalAmountCharged,
|
|
|
|
+ ];
|
|
|
|
+ return $summary;
|
|
}
|
|
}
|
|
|
|
|
|
public function orderDashboard(StoreOrder $order)
|
|
public function orderDashboard(StoreOrder $order)
|