<?php

namespace App\Models;

use CodeIgniter\Model;

class ProductoModel extends Model
{
    protected $table            = 'producto';
    protected $primaryKey       = 'id_producto';
    protected $useAutoIncrement = true;
    protected $returnType       = 'App\Entities\Producto';
    protected $useSoftDeletes   = false;
    protected $protectFields    = true;
    protected $allowedFields    = [
        'nombre',
        'descripcion',
        'precio',
        'categoria',
        'imagen_url',
        'disponible'
    ];

    protected $validationRules = [
        'nombre'     => 'required|min_length[2]|max_length[150]',
        'descripcion'=> 'permit_empty',
        'precio'     => 'required|numeric|greater_than[0]',
        'categoria'  => 'required|in_list[comida,bebida,combo]',
        'imagen_url' => 'permit_empty|max_length[500]',
        'disponible' => 'permit_empty|in_list[0,1]',
    ];
}
