<?php

namespace App\Exports;

use App\Models\Infrastructure;
use Illuminate\Support\Facades\Log;

class InfrastructureExport extends BaseExport
{
    protected function getExportColumns(): array
    {
        return [
            ['name' => 'id', 'label' => 'ID', 'type' => 'numeric'],
            ['name' => 'typeInfrastructure.libelle', 'label' => 'Type d\'infrastructure', 'type' => 'relationship', 'relation_field' => 'libelle'],
            ['name' => 'nombre_movais', 'label' => 'Nombre movais', 'type' => 'numeric'],
            ['name' => 'nombre_moyens', 'label' => 'Nombre moyens', 'type' => 'numeric'],
            ['name' => 'nombre_bons', 'label' => 'Nombre bons', 'type' => 'numeric'],
            ['name' => 'etablissement.libellefr', 'label' => 'Établissement', 'type' => 'relationship', 'relation_field' => 'libellefr'],
            ['name' => 'annee.libelle', 'label' => 'Année', 'type' => 'relationship', 'relation_field' => 'libelle'],
            ['name' => 'created_at', 'label' => 'Date de création', 'type' => 'datetime'],
            ['name' => 'updated_at', 'label' => 'Date de mise à jour', 'type' => 'datetime'],
        ];
    }

    protected function getExportTitle(): string
    {
        return 'Infrastructures';
    }

    protected function getModelClass()
    {
        return Infrastructure::class;
    }

    protected function getRelations(): array
    {
        return ['typeInfrastructure', 'etablissement', 'annee'];
    }
}
