mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Primeros cambios en cosido tapa blanda
This commit is contained in:
88
ci4/app/Models/Presupuestos/PresupuestoEstadoModel.php
Normal file
88
ci4/app/Models/Presupuestos/PresupuestoEstadoModel.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
namespace App\Models\Presupuestos;
|
||||
|
||||
class PresupuestoEstadoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "presupuesto_estados";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.estado",
|
||||
3 => "t1.is_deleted",
|
||||
4 => "t1.created_at",
|
||||
5 => "t1.updated_at",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["estado", "is_deleted"];
|
||||
protected $returnType = "App\Entities\Presupuestos\PresupuestoEstadoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "estado";
|
||||
|
||||
protected $validationRules = [
|
||||
"estado" => [
|
||||
"label" => "PresupuestoEstados.estado",
|
||||
"rules" => "trim|required|max_length[50]",
|
||||
],
|
||||
"is_deleted" => [
|
||||
"label" => "PresupuestoEstados.isDeleted",
|
||||
"rules" => "required|integer",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"estado" => [
|
||||
"max_length" => "PresupuestoEstados.validation.estado.max_length",
|
||||
"required" => "PresupuestoEstados.validation.estado.required",
|
||||
],
|
||||
"is_deleted" => [
|
||||
"integer" => "PresupuestoEstados.validation.is_deleted.integer",
|
||||
"required" => "PresupuestoEstados.validation.is_deleted.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.estado AS estado, t1.is_deleted AS is_deleted, t1.created_at AS created_at, t1.updated_at AS updated_at"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.estado", $search)
|
||||
->orLike("t1.is_deleted", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.estado", $search)
|
||||
->orLike("t1.is_deleted", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user