<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class PredictionResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id'             => $this->id,
            'match'          => new FootballMatchResource($this->whenLoaded('footballMatch')),
            'prediction'     => $this->prediction,
            'is_correct'     => $this->is_correct,
            'points_earned'  => $this->points_earned,
            'is_locked'      => $this->is_locked,
            'created_at'     => $this->created_at?->toIso8601String(),
        ];
    }
}
