<?php

namespace Modules\HR\Transformers;

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

class LeavePolicyResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'leave_type_id' => $this->leave_type_id,
            'leave_type' => $this->whenLoaded('leaveType', function () {
                return new LeaveTypeResource($this->leaveType);
            }),
            'annual_limit' => $this->annual_limit,
            'carry_forward' => $this->carry_forward,
            'encashable' => $this->encashable,
            'max_carry_forward_days' => $this->max_carry_forward_days,
            'status' => $this->status,
        ];
    }
}
