<?php

namespace App\Http\Resources\Parents;

use Illuminate\Http\Resources\Json\JsonResource;

class ParentStudentResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'id' => (int) ($this['id'] ?? 0),
            'firstname' => (string) ($this['firstname'] ?? ''),
            'lastname' => (string) ($this['lastname'] ?? ''),
            'dob' => $this['dob'] ?? null,
            'gender' => $this['gender'] ?? null,
            'registration_grade' => $this['registration_grade'] ?? null,
            'school_year' => $this['school_year'] ?? null,
            'semester' => $this['semester'] ?? null,
            'class_section' => $this['class_section'] ?? null,
            'enrollment_status' => $this['enrollment_status'] ?? null,
            'admission_status' => $this['admission_status'] ?? null,
            'disable_enroll' => (bool) ($this['disable_enroll'] ?? false),
            'allergies' => $this['allergies'] ?? [],
            'medical_conditions' => $this['medical_conditions'] ?? [],
        ];
    }
}
