<?php

namespace App\Models;

use CodeIgniter\Model;

class BranchModel extends Model
{
    protected $table         = 'branches';
    protected $primaryKey    = 'id';
    protected $returnType    = 'array';
    protected $useTimestamps = true;
    protected $dateFormat    = 'datetime';

    protected $allowedFields = ['name', 'code', 'address', 'phone', 'email', 'manager_id', 'status'];

    public function optionsForSelect(): array
    {
        return array_column(
            $this->where('status', 'active')->orderBy('name', 'ASC')->findAll(),
            'name',
            'id'
        );
    }
}
