<?php

namespace App\Resources;

use Wibiesana\Padi\Core\Resource;

class JobApplicationResource extends Resource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'job_vacancy_id' => $this->job_vacancy_id,
            'student_id' => $this->student_id,
            'application_date' => $this->application_date,
            'status' => $this->status,
            'resume_path' => $this->resume_path,

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

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

        ];
    }
}