Add total_invoices calculation to DashboardController

This commit is contained in:
Benjamin Beganović 2024-03-22 11:43:58 +01:00
parent 8a8a7e2865
commit 8adc7716d2

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Invoice Ninja (https://invoiceninja.com). * Invoice Ninja (https://invoiceninja.com).
* *
@ -12,11 +13,20 @@
namespace App\Http\Controllers\ClientPortal; namespace App\Http\Controllers\ClientPortal;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Invoice;
class DashboardController extends Controller class DashboardController extends Controller
{ {
public function index(): \Illuminate\View\View public function index(): \Illuminate\View\View
{ {
return $this->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,
]);
} }
} }