From 753ba0fe957c10dccafc52e0a819675539157a2f Mon Sep 17 00:00:00 2001 From: Christian Holladay Date: Thu, 21 Dec 2023 09:28:32 -0600 Subject: [PATCH] treat badges as collection --- app/Models/User.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Models/User.php b/app/Models/User.php index 739b511a..34bc4ebb 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Collection; use Illuminate\Support\Facades\Cache; use Laravel\Cashier\Billable; use Laravel\Fortify\TwoFactorAuthenticatable; @@ -116,11 +117,12 @@ public function activeAffiliate(): HasOne|Affiliate ->where('uses', '>', 0); } - public function getBadges(): array + public function getBadges(): array|Collection { - $badges = []; - if($this->activeAffiliate()->count()) { - $badges[] .= 'badges.affiliate'; + $badges = collect(); + if($this->activeAffiliate()->count()) + { + $badges->push('badges.affiliate'); } return $badges; }