<?php

namespace App\Http\Resources;

use App\Models\Fixture;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

/**
 * Class FixtureResource
 *
 * @mixin Fixture
 */
class FixtureResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'home_team' => $this->homeTeam->name,
            'away_team' => $this->awayTeam->name,
            'starts_at' => $this->starts_at->timestamp,
            'venue' => $this->venue,
            'status' => $this->status,
            'stage' => $this->stage,
            'home_short_name' => $this->homeTeam->short_name,
            'away_short_name' => $this->awayTeam->short_name,
        ];
    }
}
