<?php

namespace App\Http\Resources;

class PtoResource extends BaseResource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'team_member_id' => $this->team_member_id,
            'team_member' => $this->whenLoaded('teamMember', fn () => new TeamMemberResource($this->teamMember)),
            'start_date' => $this->start_date?->toDateString(),
            'end_date' => $this->end_date?->toDateString(),
            'reason' => $this->reason,
            'status' => $this->status,
            'created_at' => $this->formatDate($this->created_at),
        ];
    }
}
