mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
Trabajando en los campos del form
This commit is contained in:
96
ci4/app/Models/Configuracion/PapelFormatoModel.php
Normal file
96
ci4/app/Models/Configuracion/PapelFormatoModel.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace App\Models\Configuracion;
|
||||
|
||||
class PapelFormatoModel extends \App\Models\GoBaseModel
|
||||
{
|
||||
protected $table = "lg_papel_formato";
|
||||
|
||||
/**
|
||||
* Whether primary key uses auto increment.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $useAutoIncrement = true;
|
||||
|
||||
const SORTABLE = [
|
||||
1 => "t1.id",
|
||||
2 => "t1.ancho",
|
||||
3 => "t1.alto",
|
||||
4 => "t1.created_at",
|
||||
5 => "t1.updated_at",
|
||||
];
|
||||
|
||||
protected $allowedFields = ["ancho", "alto"];
|
||||
protected $returnType = "App\Entities\Configuracion\PapelFormatoEntity";
|
||||
|
||||
protected $useTimestamps = true;
|
||||
protected $useSoftDeletes = false;
|
||||
|
||||
protected $createdField = "created_at";
|
||||
|
||||
protected $updatedField = "updated_at";
|
||||
|
||||
public static $labelField = "ancho";
|
||||
|
||||
protected $validationRules = [
|
||||
"alto" => [
|
||||
"label" => "LgPapelFormatoes.alto",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
"ancho" => [
|
||||
"label" => "LgPapelFormatoes.ancho",
|
||||
"rules" => "required|decimal",
|
||||
],
|
||||
];
|
||||
|
||||
protected $validationMessages = [
|
||||
"alto" => [
|
||||
"decimal" => "LgPapelFormatoes.validation.alto.decimal",
|
||||
"required" => "LgPapelFormatoes.validation.alto.required",
|
||||
],
|
||||
"ancho" => [
|
||||
"decimal" => "LgPapelFormatoes.validation.ancho.decimal",
|
||||
"required" => "LgPapelFormatoes.validation.ancho.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.ancho AS ancho, t1.alto AS alto, t1.created_at AS created_at, t1.updated_at AS updated_at"
|
||||
);
|
||||
|
||||
return empty($search)
|
||||
? $builder
|
||||
: $builder
|
||||
->groupStart()
|
||||
->like("t1.id", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->orLike("t1.id", $search)
|
||||
->orLike("t1.ancho", $search)
|
||||
->orLike("t1.alto", $search)
|
||||
->orLike("t1.created_at", $search)
|
||||
->orLike("t1.updated_at", $search)
|
||||
->groupEnd();
|
||||
}
|
||||
|
||||
public function getElementsForMenu(){
|
||||
return $this->db
|
||||
->table($this->table . " t1")
|
||||
->select(
|
||||
"t1.id AS id, CONCAT(t1.ancho, ' x ', t1.alto) AS tamanio"
|
||||
)->get()->getResultObject();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user