Files
crm-ms1/v4_ci4/app/Modules/Inventaire/Models/InvGenresModel.php
2026-05-27 11:44:10 -04:00

47 lines
1.0 KiB
PHP

<?php
namespace Modules\Inventaire\Models;
use CodeIgniter\Model;
class InvGenresModel extends Model
{
protected $table = 'inv_genres';
protected $primaryKey = 'inv_id';
protected $returnType = 'array';
protected $allowedFields = [
'inv_nom_fr',
'inv_nom_en',
'inv_genre_type',
'inv_defaut',
'inv_actif',
'inv_trie',
'inv_color',
'inv_text_color'
];
public function getOptionsByType(string $type, bool $onlyActive = true): array
{
$builder = $this->builder();
$builder->where('inv_genre_type', $type);
if ($onlyActive) {
$builder->where('inv_actif', 1);
}
return $builder
->orderBy('inv_trie', 'ASC')
->get()
->getResultArray();
}
public function getOptionById(int $id): ?array
{
return $this->builder()
->where('inv_id', $id)
->where('inv_actif', 1)
->get()
->getRowArray();
}
}