<?php

namespace App\Resources;

use Wibiesana\Padi\Core\Resource;

class ExtracurricularMemberResource extends Resource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'extracurricular_id' => $this->extracurricular_id,
            'student_id' => $this->student_id,
            'grade' => $this->grade,
            'notes' => $this->notes,

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

            // Flattened Fields
            'extracurricular_name' => $this->extracurricular['name'] ?? null,
            'student_name' => $this->student['name'] ?? null,

        ];
    }
}