From c9b3ffd895560be55af65ed88cd39fb506902bae Mon Sep 17 00:00:00 2001 From: Xinecraft Date: Fri, 31 May 2024 01:07:46 +0530 Subject: [PATCH] max link error fix --- app/Http/Controllers/Api/ApiAccountLinkController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Api/ApiAccountLinkController.php b/app/Http/Controllers/Api/ApiAccountLinkController.php index 76383e441..7e672e26a 100644 --- a/app/Http/Controllers/Api/ApiAccountLinkController.php +++ b/app/Http/Controllers/Api/ApiAccountLinkController.php @@ -40,9 +40,10 @@ public function verify(Request $request, PluginSettings $pluginSettings) // Check if current user has enough available slot to link the player. $user = User::where('id', $valid['user_id'])->first(); - $max_slots = $pluginSettings->max_players_link_per_account; // Total number of players that can be linked to account - if ($user->players()->count() >= $max_slots) { - $this->error(__('You already have max :max_slots players linked!', ['max_slots' => $max_slots]), 'max-players-reached'); + $maxSlots = $pluginSettings->max_players_link_per_account; // Total number of players that can be linked to account + $linkedPlayers = $user->players()->count(); // Number of players already linked to account + if ($linkedPlayers >= $maxSlots) { + return $this->error(__('You already have max :max_slots players linked!', ['max_slots' => $maxSlots]), 'max-players-reached'); } // Link player to user