<?php

namespace App\Http\Resources;

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

class KitchenTicketResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'order_id' => $this->order_id,
            'order_number' => $this->order?->order_number,
            'ticket_number' => $this->ticket_number,
            'status' => $this->status,
            'priority' => $this->priority,
            'notes' => $this->notes,
            'started_at' => $this->started_at,
            'ready_at' => $this->ready_at,
            'served_at' => $this->served_at,
            'created_at' => $this->created_at,
            'items' => KitchenTicketItemResource::collection($this->whenLoaded('items')),
        ];
    }
}
