mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
namespace App\Models\Configuracion;
|
|
|
|
class UbicacionesModel extends \App\Models\BaseModel
|
|
{
|
|
protected $table = "ubicaciones";
|
|
|
|
/**
|
|
* Whether primary key uses auto increment.
|
|
*
|
|
* @var bool
|
|
*/
|
|
protected $useAutoIncrement = true;
|
|
|
|
const SORTABLE = [
|
|
1 => "t1.id",
|
|
2 => "t1.nombre"
|
|
];
|
|
|
|
protected $allowedFields = ["nombre"];
|
|
protected $returnType = "App\Entities\Configuracion\UbicacionesEntity";
|
|
|
|
public static $labelField = "nombre";
|
|
|
|
protected $validationRules = [
|
|
"nombre" => [
|
|
"label" => "Paises.nombre",
|
|
"rules" => "trim|required|max_length[255]",
|
|
]
|
|
];
|
|
|
|
protected $validationMessages = [
|
|
"nombre" => [
|
|
"max_length" => "Paises.validation.nombre.max_length",
|
|
"required" => "Paises.validation.nombre.required",
|
|
]
|
|
];
|
|
|
|
/**
|
|
* Get resource data.
|
|
*
|
|
* @param string $search
|
|
*
|
|
* @return \CodeIgniter\Database\BaseBuilder
|
|
*/
|
|
public function getResource(string $search = "")
|
|
{
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.id AS id, t1.nombre AS nombre"
|
|
);
|
|
|
|
return empty($search)
|
|
? $builder
|
|
: $builder
|
|
->groupStart()
|
|
->like("t1.id", $search)
|
|
->orLike("t1.nombre", $search)
|
|
->groupEnd();
|
|
}
|
|
}
|