Skip to content

Commit

Permalink
max link error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed May 30, 2024
1 parent 145905b commit c9b3ffd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/Http/Controllers/Api/ApiAccountLinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c9b3ffd

Please sign in to comment.