<?php

namespace App\Http\Resources\Whatsapp;

use Illuminate\Http\Resources\Json\JsonResource;

class WhatsappClassSectionContactResource extends JsonResource
{
    public function toArray($request): array
    {
        return [
            'class_section_id' => (int) ($this['class_section_id'] ?? 0),
            'class_section_name' => (string) ($this['class_section_name'] ?? ''),
            'semester' => (string) ($this['semester'] ?? ''),
            'school_year' => (string) ($this['school_year'] ?? ''),
            'description' => (string) ($this['description'] ?? ''),
            'main_teachers' => array_values($this['main_teachers'] ?? []),
            'teacher_assistants' => array_values($this['teacher_assistants'] ?? []),
            'parents' => WhatsappClassSectionParentResource::collection($this['parents'] ?? []),
        ];
    }
}
