<?php

namespace App\Models;

use CodeIgniter\Model;

class DocumentTypeModel extends Model
{
    protected $table         = 'document_types';
    protected $primaryKey    = 'id';
    protected $returnType    = 'array';
    protected $useTimestamps = true;
    protected $allowedFields = ['name', 'slug'];

    public function getDropdown(): array
    {
        $rows = $this->orderBy('name', 'ASC')->findAll();
        $list = [];
        foreach ($rows as $row) {
            $list[$row['id']] = $row['name'];
        }
        return $list;
    }
}
