@php $squadsRows = collect($soldPlayers)->merge($unsoldPlayers)->values(); // Only sold players the replacement rules can actually act on carry a // button; the rest of the table renders exactly as before. $replaceable = $replaceablePlayers ?? []; $candidates = $replacementCandidates ?? []; @endphp

Final Squads & Player List

@forelse ($squadsRows as $row) @php // Any unsold player can fill any slot, so the button turns on // for every sold row as soon as the league has someone left. $slot = $row['status'] === 'sold' && $candidates !== [] ? ($replaceable[$row['playerId']] ?? null) : null; @endphp
{{ $row['playerName'] }}
{{ $row['teamName'] }}
{{ $row['role'] }}
{{ $row['categoryLabel'] ?? $row['categoryName'] }}
{{ $row['soldPrice'] }}
@if ($row['status'] === 'sold') @else @endif
@if ($slot) @endif
@empty

No players found for this auction.

@endforelse
{{-- Replacement dialog. One instance for the whole table; the Replace buttons hand it the slot being filled and the script narrows the candidate list to that player's category and price. --}}