@php global $loop; use App\Domain\Football\Match\PredictionResult; use Carbon\Carbon; $isStep = ($type ?? 'single') === 'step'; /** กรองผลงานตามประเภท */ $filterPreds = function ($collection) use ($isStep) { if (!$collection) return collect(); $want = $isStep ? 'step' : 'single'; return $collection->filter(fn ($p) => strtolower(trim($p->type ?? '')) === $want); }; /** ✅ คำนวณแต้มฐาน/โบนัส และรวมเป็น points */ $sumStats = function ($preds) { $base = (float) $preds->sum(fn ($p) => (float) ($p->gain_amount ?? 0)); $bonus = (float) $preds->sum(fn ($p) => (float) ($p->gain_bonus_amount ?? 0)); return [ 'win' => $preds->where('result', PredictionResult::WIN->value)->count(), 'win_half' => $preds->where('result', PredictionResult::HALF->value)->count(), 'draw' => $preds->where('result', PredictionResult::DRAW->value)->count(), 'lose' => $preds->where('result', PredictionResult::LOSE->value)->count(), 'base' => $base, 'bonus' => $bonus, 'points' => $base + $bonus, ]; }; /** --- Weekly (อ้างอิงค่าจาก $week ถ้ามี, ถ้าไม่มีก็ใช้ request, ถ้าไม่มีอีกก็ใช้วันนี้) --- */ $typeParam = $isStep ? 'step' : 'single'; $weekRef = isset($week) && $week ? Carbon::parse($week) : (request('week') ? Carbon::parse(request('week')) : now()); $wkStart = $weekRef->copy()->startOfWeek(Carbon::TUESDAY)->startOfDay(); $wkEnd = $wkStart->copy()->addDays(6)->endOfDay(); $prevWeek = $wkStart->copy()->subWeek()->toDateString(); $nextWeek = $wkStart->copy()->addWeek()->toDateString(); /** --- Monthly (อ้างอิงค่าจาก $month ถ้ามี, ถ้าไม่มีก็ใช้ request, ถ้าไม่มีอีกก็ใช้เดือนนี้) --- */ $monthParam = isset($month) && $month ? $month : (request('month') ?: now()->format('Y-m')); $monthRef = Carbon::createFromFormat('Y-m', substr($monthParam, 0, 7)); $mnStart = $monthRef->copy()->startOfMonth()->startOfDay(); $mnEnd = $monthRef->copy()->endOfMonth()->endOfDay(); $prevMonth = $monthRef->copy()->subMonth()->format('Y-m'); $nextMonth = $monthRef->copy()->addMonth()->format('Y-m'); @endphp
*** เริ่มนับผลอันดับคะแนนใหม่ทุกวันอังคาร
อันดับ | ชื่อเล่น | 10 ผลงานล่าสุด | ชนะ | ชนะครึ่ง | เสมอ | แพ้ | คะแนน |
---|---|---|---|---|---|---|---|
{{ $showRank }} | {{ $item->nick_name }} @php $authId = auth()->id(); @endphp @if ($item->id === $authId) @elseif (!empty($item->targetViewPrediction) && count($item->targetViewPrediction) > 0) @elseif (!empty($item->predic_today_count) && (int) $item->predic_today_count > 0) @endif |
@foreach ($preds->take(10) as $prediction)
{!! PredictionResult::toBadge($prediction->result ?? null) !!}
@endforeach
|
{{ $stats['win'] }} | {{ $stats['win_half'] }} | {{ $stats['draw'] }} | {{ $stats['lose'] }} |
{{ number_format($pointsTotal, 0) }}
@if ($isStep)
(+โบนัส {{ number_format($bonusTotal, 0) }})
@endif
|
อันดับ | ชื่อเล่น | 10 ผลงานล่าสุด | ชนะ | ชนะครึ่ง | เสมอ | แพ้ | คะแนน |
---|---|---|---|---|---|---|---|
{{ $showRank }} | {{ $item->nick_name }} @if ($item->id === auth()->id()) @endif |
@foreach ($preds->take(10) as $prediction)
{!! PredictionResult::toBadge($prediction->result ?? null) !!}
@endforeach
|
{{ $stats['win'] }} | {{ $stats['win_half'] }} | {{ $stats['draw'] }} | {{ $stats['lose'] }} |
{{ number_format($pointsTotal, 0) }}
@if ($isStep)
(+โบนัส {{ number_format($bonusTotal, 0) }})
@endif
|