<?php

namespace App\Exports;

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

class EtablissementExport extends BaseExport
{
    protected function getExportColumns(): array
    {
        return [
            ['name' => 'id', 'label' => 'ID', 'type' => 'numeric'],
            ['name' => 'libellear', 'label' => 'Libellé (Arabe)', 'type' => 'text'],
            ['name' => 'libellefr', 'label' => 'Libellé (Français)', 'type' => 'text'],
            ['name' => 'cycle.libelle', 'label' => 'Cycle', 'type' => 'relationship', 'relation_field' => 'libelle'],
            ['name' => 'code', 'label' => 'Code', 'type' => 'text'],
            ['name' => 'latitude', 'label' => 'Latitude', 'type' => 'numeric'],
            ['name' => 'longitude', 'label' => 'Longitude', 'type' => 'numeric'],
            ['name' => 'etat', 'label' => 'État', 'type' => 'text'],
            ['name' => 'commune.libelle', 'label' => 'Commune', '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 'Etablissements';
    }

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

    protected function getRelations(): array
    {
        return ['cycle', 'commune'];
    }
}
