<?php

namespace App\Resources;

use Wibiesana\Padi\Core\Resource;

class StudentAchievementResource extends Resource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'student_id' => $this->student_id,
            'achievement_name' => $this->achievement_name,
            'category' => $this->category,
            'level' => $this->level,
            'achievement_date' => $this->achievement_date,
            'notes' => $this->notes,
            'certificate_path' => $this->certificate_path,

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

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

        ];
    }
}