mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
trabajando en papel generico. Problema al generar el datatable
This commit is contained in:
92
ci4/app/Models/Configuracion/PapelGenericoModel.php
Normal file
92
ci4/app/Models/Configuracion/PapelGenericoModel.php
Normal file
@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class PapelGenericoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_papel_generico";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.nombre",
|
||||
3 => "t1.code",
|
||||
4 => "t1.code_ot",
|
||||
5 => "t1.show_in_client",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["nombre", "code", "code_ot", "show_in_client"];
|
||||
protected $returnType = "App\Entities\Configuracion\PapelGenericoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "nombre";
|
||||
|
||||
protected $validationRules = [
|
||||
"code" => [
|
||||
"label" => "PapelGenericoes.code",
|
||||
"rules" => "trim|max_length[5]",
|
||||
],
|
||||
"code_ot" => [
|
||||
"label" => "PapelGenericoes.codeOt",
|
||||
"rules" => "trim|max_length[5]",
|
||||
],
|
||||
"nombre" => [
|
||||
"label" => "PapelGenericoes.nombre",
|
||||
"rules" => "trim|required|max_length[255]",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"code" => [
|
||||
"max_length" => "PapelGenericoes.validation.code.max_length",
|
||||
],
|
||||
"code_ot" => [
|
||||
"max_length" => "PapelGenericoes.validation.code_ot.max_length",
|
||||
],
|
||||
"nombre" => [
|
||||
"max_length" => "PapelGenericoes.validation.nombre.max_length",
|
||||
"required" => "PapelGenericoes.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, t1.code AS code, t1.code_ot AS code_ot, t1.show_in_client AS show_in_client"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.nombre", $search)
|
||||
->orLike("t1.code", $search)
|
||||
->orLike("t1.code_ot", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user