@extends('admin.layouts.main.admin_theme') @section('styles') @endsection @section('admin_content')

Edit Competition

{{-- Top-Level Navigation Tabs (Consistent with Settings page) --}}
{{-- 1. Competition Details Tab --}}
@csrf

Edit Competition Details

Cancel
{{-- 1. Basic Metadata --}}
@error('sport_id') {{ $message }} @enderror
@error('title') {{ $message }} @enderror
{{-- Descriptions & Who Wins --}}
@error('description') {{ $message }} @enderror
@error('card_desc') {{ $message }} @enderror
@error('rules') {{ $message }} @enderror
{{-- 2. Scheduling (Start Time & End Time UTC) --}}
@error('starts_at') {{ $message }} @enderror
@error('ends_at') {{ $message }} @enderror
{{-- 3. Prize Type (Standalone Row) --}}
@error('prize_type') {{ $message }} @enderror
@php $currentPrizeType = old('prize_type', $competition->prize_type ?? 'Cash Prize'); $isFreeMembership = in_array($currentPrizeType, ['Free months pro membership on competitions', 'Free Months Pro Membership on Competitions', 'Free Months', 'Membership']); @endphp {{-- 4. Prize Pool / Membership Duration + Total Winners --}}
(Default from Admin Settings > Free Months on Competition) @error('membership_prize_months') {{ $message }} @enderror
@error('prize_pool_amount') {{ $message }} @enderror
@error('total_winners') {{ $message }} @enderror
{{-- 5. Ranges (One Row) --}}
@error('from_range') {{ $message }} @enderror
@error('to_range') {{ $message }} @enderror
@error('interval') {{ $message }} @enderror
{{-- Eligibility --}}
@error('eligibility') {{ $message }} @enderror
{{-- 6. MARKET TYPE SETTINGS SECTION --}}
Market Type Settings
Market and Period apply to every match (or every player matchup) added below
@error('market_type') {{ $message }} @enderror
@php $selectedMarket = old('market', $competition->matches_data[0]['market'] ?? ''); @endphp @error('market') {{ $message }} @enderror
@php $selectedPeriod = old('period', $competition->matches_data[0]['period'] ?? 'Full Time'); $knownPeriods = ['Full Time', '1st Half', '2nd Half', '1st Quarter', '2nd Quarter', '3rd Quarter', '4th Quarter', 'Q1', 'Q2', 'Q3', 'Q4', '1st Period', '2nd Period', '3rd Period', 'Regular Time', 'Overtime']; $foundPeriod = false; @endphp @error('period') {{ $message }} @enderror
@error('total_matches') {{ $message }} @enderror
{{-- 6. MATCH CARDS --}}
Matches / Fixtures
@php $savedMatches = !empty($competition->matches_data) ? $competition->matches_data : [['match_id' => '']]; $isPlayerProps = (old('market_type', $competition->match_category) === 'Player Props'); @endphp @php $deletedStatuses = [ 'postponed', 'pst', 'post', 'postp.', 'delayed', 'cancelled', 'canceled', 'cancel', 'canc.', 'canc', 'can', 'void', 'abandoned', 'aband.', 'abd', 'suspended', 'interrupted', 'walkover', 'wo', ]; @endphp @foreach ($savedMatches as $index => $match) @php $matchId = $match['match_id'] ?? null; $savedMatchups = !empty($match['matchups']) ? $match['matchups'] : [['home_player_id' => '', 'away_player_id' => '']]; $matchModel = $matchId ? $scheduledMatches->firstWhere('id', (int)$matchId) : null; if (!$matchModel && $matchId) { $matchModel = \App\Models\SportMatch::find((int)$matchId); } $isPostponed = !empty($match['is_postponed']); if (!$isPostponed && $matchModel) { $rawStatus = strtolower(trim((string)$matchModel->match_status)); $isPostponed = ($matchModel->match_status_type === \App\Models\SportMatch::STATUS_DELETED) || in_array($rawStatus, $deletedStatuses, true); } if (!$isPostponed && $matchModel && $matchModel->provider_match_id && isset($competition->sport_id)) { $isPostponed = \App\Models\SportMatchExclusion::where('sport_id', $competition->sport_id) ->where('provider_match_id', (string)$matchModel->provider_match_id) ->where('is_active', true) ->exists(); } @endphp
Match {{ $index + 1 }} * @if($isPostponed) Postponed @endif
@if(!$isPostponed) @endif
@php $hintText = $match['match_text'] ?? ''; if ($hintText === 'undefined') { $hintText = !empty($match['home_team']) ? ($match['home_team'] . ' vs ' . ($match['away_team'] ?? 'Away')) : ''; } @endphp
{{ $hintText }}
@if($isPostponed)
This match is postponed and excluded from upcoming schedules. It remains recorded in this competition and cannot be removed.
@endif
{{-- Player Matchups Container --}}
Player Matchups
@foreach ($savedMatchups as $muIndex => $mu)
Player Matchup {{ $muIndex + 1 }}
@php $playerAId = $mu['home_player_id'] ?? $mu['player_a_id'] ?? ''; $playerAName = $mu['home_player_name'] ?? $mu['player_a_name'] ?? $playerAId; $playerBId = $mu['away_player_id'] ?? $mu['player_b_id'] ?? ''; $playerBName = $mu['away_player_name'] ?? $mu['player_b_name'] ?? $playerBId; @endphp
@endforeach
@endforeach
@php $showAssignedWinners = (old('status', $competition->status) === 'resulted') && (old('prize_type', $competition->prize_type ?? 'Cash Prize') === 'Cash Prize'); $savedBreakdown = !empty($competition->prize_breakdown) ? $competition->prize_breakdown : []; $initialAssignedCount = count($savedBreakdown); $maxTippers = isset($tippersCount) ? (int)$tippersCount : 0; @endphp {{-- Assigned Winners Section (Only visible when Status is Resulted and Prize Type is Cash Prize) --}}
Assigned Winners *
@if($maxTippers > 0) {{ $maxTippers }} {{ Str::plural('user', $maxTippers) }} tipped in this competition. Max allowed: {{ $maxTippers }}. @else No users have tipped on this competition yet. @endif
@foreach ($savedBreakdown as $wIdx => $winner) @php $rankNum = $winner['rank'] ?? ($wIdx + 1); $selectedUserId = $winner['user_id'] ?? ''; $winnerAmount = $winner['amount'] ?? ''; @endphp
@if($isFreeMembership) @else @endif
@endforeach
{{-- 7. Status --}}
@error('status') {{ $message }} @enderror
{{-- 8. T&C (CKEditor) --}}
Terms & Conditions (T&C) *
{{-- 2. Leaderboard Tab --}}
@php $isCompMembershipPrize = $competition->isMembershipPrize(); @endphp @if(isset($leaderboardEntries) && $leaderboardEntries->count() > 0)

Leaderboard (Sorted by Least Margin / Best Score)

@php $savedWinnerUserIds = collect($competition->prize_breakdown ?? [])->pluck('user_id')->filter()->map(fn($id) => (int)$id)->all(); @endphp @foreach($leaderboardEntries as $index => $entry) @php $u = $entry->user; $userId = $entry->user_id; $userName = $u?->name ?? 'User #' . $userId; $userEmail = $u?->email ?? '—'; $isWinner = in_array((int)$userId, $savedWinnerUserIds, true); $winnerAmount = 0; if ($isWinner && is_array($competition->prize_breakdown)) { foreach ($competition->prize_breakdown as $w) { if ((int)($w['user_id'] ?? 0) === (int)$userId) { $winnerAmount = $w['amount'] ?? 0; break; } } } @endphp @endforeach
No. User Email Correct / Points Total Margin / Score Action
@if($isCompMembershipPrize && $u?->has_lifetime_access) Lifetime Member @elseif(! ($isCompMembershipPrize && $isWinner)) @endif {{ $index + 1 }} {{ $userName }} @if($u?->has_lifetime_access) Lifetime @elseif($u?->is_subscribed) Subscribed @endif {{ $userEmail }} {{ $entry->points !== null ? $entry->points : 0 }} {{ $entry->score !== null ? number_format((float)$entry->score, 2) : '0.00' }} @if($isWinner)
✓ Winner Edit Delete
@elseif($isCompMembershipPrize && $u?->has_lifetime_access) Lifetime Member @else @endif
@else

No user tips / entries submitted for this competition yet.

@endif
{{-- Add Winner Modal --}}

Add Winner

×
{{-- Bulk Allocate Prize Modal --}} @endsection @section('scripts') @endsection