<?php

namespace Modules\HR\Transformers;

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

class HolidayResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'holiday_group_id' => $this->holiday_group_id,
            'holiday_group' => $this->whenLoaded('holidayGroup', function () {
                return [
                    'id' => $this->holidayGroup->id,
                    'name' => $this->holidayGroup->name,
                ];
            }),
            'title' => $this->title,
            'holiday_date' => $this->holiday_date,
            'is_optional' => (bool) $this->is_optional,
            'remarks' => $this->remarks,
            'status' => $this->status,
        ];
    }
}
