@if (liveMatchData()->count() != 0)
@php
$currentDateTime = now();
$activeMatches = \App\Models\MatchActivity::where('is_match_completed', 'N')
->where('match_start_time', '<=', $currentDateTime)
->where('match_approval_end_time', '>=', $currentDateTime)
->orderBy('match_start_time', 'asc')
->get();
$nextMatchExists = $activeMatches->contains(function ($match) {
return in_array($match->match_type, ['semi_final', 'final']);
});
if (!$nextMatchExists) {
$upcomingMatch = \App\Models\MatchActivity::where('is_match_completed', 'N')
->where('match_start_time', '>', $currentDateTime)
->orderBy('match_start_time', 'asc')
->first();
$nextMatchExists =
$upcomingMatch && in_array($upcomingMatch->match_type, ['semi_final', 'final']);
}
@endphp
@foreach (liveMatchData()->toArray() as $index => $liveMatchData)
@if ($nextMatchExists)
@endforeach
@else
Currently no matches are live now.
@endif