<?php

namespace App\Resources;

use Wibiesana\Padi\Core\Resource;

class IndustrialVisitResource extends Resource
{
    public function toArray($request): array
    {
        return [
            'id' => $this->id,
            'company_id' => $this->company_id,
            'teacher_in_charge_id' => $this->teacher_in_charge_id,
            'class_name' => $this->class_name,
            'visit_date' => $this->visit_date,
            'documentation_path' => $this->documentation_path,
            'notes' => $this->notes,

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

            // Flattened Fields
            'company_name' => $this->company['name'] ?? null,
            'teacherInCharge_name' => $this->teacherInCharge['name'] ?? null,

        ];
    }
}