<?php

namespace Entity\Model;

use Helpers\QueryBuilder\QueryBuilder;

class Periodes extends QueryBuilder
{
    protected string $table = 'PERIODES with (nolock)';
    protected string $primaryKey = 'CODE_PER';
    protected string $libelle = 'LIBELLE';

    /**
     * @return array<string|int,string>
     */
    public function listChoiceActive():array
    {
        return array_column(
            array_filter(
                $this->fetchAll([], ['tri_DATE_DEB' => 'desc']),
                function ($entity) {
                    return $entity['DATE_DEB'] <= date('Ymd');
                }
            ),
            'LIBELLE',
            'CODE_PER'
        );
    }
}
