<?php

namespace App\Resources;

use Wibiesana\Padi\Core\Resource;

class ExtracurricularResource extends Resource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'description' => $this->description,
            'advisor_teacher_id' => $this->advisor_teacher_id,
            'schedule' => $this->schedule,

            // Relations
            'advisorTeacher' => $this->whenLoaded('advisorTeacher'),

            // Flattened Fields
            'advisorTeacher_name' => $this->advisorTeacher['name'] ?? null,

        ];
    }
}