<?php

namespace App\Models;

use CodeIgniter\Model;

class LocalModel extends Model
{
    protected $table            = 'local';
    protected $primaryKey       = 'id_local';
    protected $useAutoIncrement = true;
    protected $returnType       = 'App\Entities\Local';
    protected $useSoftDeletes   = false;
    protected $protectFields    = true;
    protected $allowedFields    = [
        'nombre',
        'direccion',
        'distrito',
        'ciudad',
        'telefono',
        'estado'
    ];

    protected $validationRules = [
        'nombre'    => 'required|min_length[2]|max_length[150]',
        'direccion' => 'required|min_length[5]|max_length[255]',
        'distrito'  => 'permit_empty|max_length[100]',
        'ciudad'    => 'required|max_length[100]',
        'telefono'  => 'permit_empty|max_length[20]',
        'estado'    => 'permit_empty|in_list[0,1]',
    ];
}
