From 9fc9db8a2f9cde86bccd74101a3a5484e61f0e14 Mon Sep 17 00:00:00 2001 From: isaacclad Date: Sat, 6 Jun 2026 21:55:13 +0000 Subject: [PATCH] Add User avatarUrl helper and harden dashboard billing lookup. Fixes dashboard 500 after SSO when layout renders profile avatar. Co-authored-by: Cursor --- app/Http/Controllers/Qr/OverviewController.php | 14 +++++++++++++- app/Models/User.php | 7 +++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Qr/OverviewController.php b/app/Http/Controllers/Qr/OverviewController.php index 1bd180e..c967b05 100644 --- a/app/Http/Controllers/Qr/OverviewController.php +++ b/app/Http/Controllers/Qr/OverviewController.php @@ -8,7 +8,9 @@ use App\Services\Billing\BillingClient; use App\Services\Qr\QrCodeManagerService; use App\Support\Qr\QrTypeCatalog; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use Illuminate\View\View; +use Throwable; class OverviewController extends Controller { @@ -38,12 +40,22 @@ class OverviewController extends Controller ->get() ->sum('scans_30d'); + $balanceMinor = 0; + try { + $balanceMinor = $this->billing->balanceMinor($user->public_id); + } catch (Throwable $e) { + Log::warning('QR Plus dashboard could not load wallet balance', [ + 'user' => $user->public_id, + 'error' => $e->getMessage(), + ]); + } + return view('qr.dashboard', [ 'wallet' => $wallet, 'recentCodes' => $codes, 'activeCount' => $activeCount, 'scans30d' => (int) $scans30d, - 'balanceMinor' => $this->billing->balanceMinor($user->public_id), + 'balanceMinor' => $balanceMinor, ]); } } diff --git a/app/Models/User.php b/app/Models/User.php index 3021385..1a15490 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -44,4 +44,11 @@ class User extends Authenticatable ['credit_balance' => 0, 'qr_codes_total' => 0, 'scans_total' => 0, 'status' => QrWallet::STATUS_ACTIVE], ); } + + public function avatarUrl(): ?string + { + $url = trim((string) $this->avatar_url); + + return $url !== '' ? $url : null; + } }