diff --git a/app/Http/Controllers/Qr/QrCodeController.php b/app/Http/Controllers/Qr/QrCodeController.php index 4989ac4..879af1b 100644 --- a/app/Http/Controllers/Qr/QrCodeController.php +++ b/app/Http/Controllers/Qr/QrCodeController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Qr; use App\Http\Controllers\Controller; use App\Models\QrCode; +use App\Models\QrEventRegistration; use App\Models\QrWallet; use App\Services\Billing\BillingClient; use App\Services\Qr\QrAnalyticsService; @@ -44,9 +45,12 @@ class QrCodeController extends Controller $wallet = $this->manager->walletFor($account); $qrCodes = $account->qrCodes() ->whereIn('type', QrTypeCatalog::eventTypes()) + ->withCount(['eventRegistrations as registrations_count' => fn ($q) => $q->where('status', QrEventRegistration::STATUS_CONFIRMED)]) ->latest() ->get(); + $totalRegistrations = (int) $qrCodes->sum('registrations_count'); + $ladillWalletBalance = 0.0; try { $ladillWalletBalance = $this->platformBilling->balanceMinor($account->public_id) / 100; @@ -60,6 +64,7 @@ class QrCodeController extends Controller return view('qr-codes.index', [ 'wallet' => $wallet, 'qrCodes' => $qrCodes, + 'totalRegistrations' => $totalRegistrations, 'pricePerQr' => QrWallet::pricePerQr(), 'minTopup' => QrWallet::minTopupGhs(), 'ladillWalletBalance' => $ladillWalletBalance, diff --git a/resources/views/qr-codes/index.blade.php b/resources/views/qr-codes/index.blade.php index 2422d6b..7712510 100644 --- a/resources/views/qr-codes/index.blade.php +++ b/resources/views/qr-codes/index.blade.php @@ -41,15 +41,15 @@

GHS {{ number_format($wallet->spendableBalance(), 2) }}

-

QR balance

+

Account balance

{{ $qrCodes->count() }}

-

QR codes

+

Events

-

{{ number_format($wallet->scans_total) }}

-

Total scans

+

{{ number_format($totalRegistrations) }}

+

Registrations

@@ -58,10 +58,10 @@
-

Your QR codes

+

Your events

@if($qrCodes->isEmpty()) -

No QR codes yet. Create your first QR code to get started.

+

No events yet. Create your first event to get started.

@else
@foreach($qrCodes as $code) @@ -74,7 +74,7 @@

{{ $code->typeLabel() }} ยท {{ $code->publicUrl() }}

-

{{ number_format($code->scans_total) }} scans

+

{{ number_format($code->registrations_count) }} registered

{{ $code->is_active ? 'Active' : 'Paused' }}