From 8adc7716d2afa9b1b3e179539ec3011fb2e7e4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 22 Mar 2024 11:43:58 +0100 Subject: [PATCH] Add total_invoices calculation to DashboardController --- .../Controllers/ClientPortal/DashboardController.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/ClientPortal/DashboardController.php b/app/Http/Controllers/ClientPortal/DashboardController.php index 24d06e8b82dc..ca5e8825b1b3 100644 --- a/app/Http/Controllers/ClientPortal/DashboardController.php +++ b/app/Http/Controllers/ClientPortal/DashboardController.php @@ -1,4 +1,5 @@ render('dashboard.index'); + $total_invoices = Invoice::withTrashed() + ->where('client_id', auth()->guard('contact')->user()->client_id) + ->where('is_deleted', 0) + ->whereIn('status_id', [Invoice::STATUS_SENT, Invoice::STATUS_PARTIAL, Invoice::STATUS_PAID]) + ->sum('amount'); + + return $this->render('dashboard.index', [ + 'total_invoices' => $total_invoices, + ]); } }