Files
safekat/ci4/app/Models/Clientes/ClientePlantillaPreciosModel.php
2024-05-02 23:52:46 +02:00

75 lines
1.6 KiB
PHP
Executable File

<?php
namespace App\Models\Clientes;
class ClientePlantillaPreciosModel extends \App\Models\BaseModel
{
protected $table = "cliente_plantilla_precios";
const SORTABLE = [
0 => "t1.nombre",
];
/**
* Whether primary key uses auto increment.
*
* @var bool
*/
protected $useAutoIncrement = true;
protected $allowedFields = ["nombre", "is_deleted", "deleted_at", "created_at", "updated_at"];
protected $returnType = "App\Entities\Clientes\ClientePlantillaPreciosEntity";
protected $useTimestamps = true;
protected $useSoftDeletes = false;
protected $createdField = "created_at";
protected $updatedField = "updated_at";
public static $labelField = "nombre";
protected $validationRules = [
"nombre" => [
"label" => "ClientePrecios.nombre",
"rules" => "trim|max_length[100]",
],
];
protected $validationMessages = [
"nombre" => [
"max_length" => "ClientePrecios.validation.max_length",
],
];
/**
* Get resource data.
*
* @param string $search
*
* @return \CodeIgniter\Database\BaseBuilder
*/
public function getResource(string $search = "", $cliente_id = -1)
{
$builder = $this->db
->table($this->table . " t1")
->select(
"t1.id as id, t1.nombre AS nombre"
);
$builder->where('t1.is_deleted', 0);
return empty($search)
? $builder
: $builder
->groupStart()
->like("t1.nombre", $search)
->groupEnd();
}
}