<?php

namespace App\Http\Resources\Students;

use Illuminate\Http\Resources\Json\JsonResource;

class StudentAssignmentResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'student_id' => (int) ($this['student_id'] ?? 0),
            'name' => (string) ($this['name'] ?? ''),
            'age' => $this['age'] ?? null,
            'email' => $this['email'] ?? null,
            'phone' => $this['phone'] ?? null,
            'registration_grade' => $this['registration_grade'] ?? null,
            'class_section_name' => $this['class_section_name'] ?? null,
            'class_section_names' => $this['class_section_names'] ?? [],
            'class_section_ids' => $this['class_section_ids'] ?? [],
            'new_student' => $this['new_student'] ?? null,
            'registration_date' => $this['registration_date'] ?? null,
            'school_year' => $this['school_year'] ?? null,
            'semester' => $this['semester'] ?? null,
        ];
    }
}
