mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
69 lines
1.8 KiB
PHP
69 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Presupuestos;
|
|
|
|
class PresupuestoPreimpresionesModel extends \App\Models\GoBaseModel
|
|
{
|
|
protected $table = "presupuesto_preimpresiones";
|
|
|
|
/**
|
|
* Whether primary key uses auto increment.
|
|
*
|
|
* @var bool
|
|
*/
|
|
protected $useAutoIncrement = true;
|
|
|
|
const SORTABLE = [
|
|
0 => "t2.nombre",
|
|
1 => "t1.precio_unidad",
|
|
2 => "t1.precio_total"
|
|
];
|
|
|
|
protected $allowedFields = ["presupuesto_id", "tarifa_preimpresion_id", "nombre", "precio_total", "precio_unidad"];
|
|
protected $returnType = "App\Entities\Presupuestos\PresupuestoPreimpresionesEntity";
|
|
|
|
protected $useTimestamps = true;
|
|
protected $useSoftDeletes = false;
|
|
|
|
protected $createdField = "created_at";
|
|
protected $updatedField = "updated_at";
|
|
|
|
public static $labelField = "nombre";
|
|
|
|
protected $validationRules = [
|
|
"precio_total" => [
|
|
"label" => "Presupuestos.precioTotal",
|
|
"rules" => "decimal|required",
|
|
],
|
|
];
|
|
|
|
protected $validationMessages = [
|
|
"precio_total" => [
|
|
"decimal" => "Presupuestos.validation.decimal",
|
|
"requerido" => "Presupuestos.validation.decimal",
|
|
],
|
|
];
|
|
|
|
|
|
/**
|
|
* Get resource data.
|
|
*
|
|
* @param string $search
|
|
*
|
|
* @return \CodeIgniter\Database\BaseBuilder
|
|
*/
|
|
public function getResource($presupuesto_id = -1)
|
|
{
|
|
$builder = $this->db
|
|
->table($this->table . " t1")
|
|
->select(
|
|
"t1.id AS id, t1.tarifa_preimpresion_id AS tarifa_preimpresion_id, t1.precio_unidad AS precio_unidad, t1.precio_total AS precio_total, t2.nombre AS nombre"
|
|
);
|
|
|
|
$builder->where('t1.presupuesto_id', $presupuesto_id);
|
|
$builder->join("lg_tarifa_preimpresion t2", "t1.tarifa_preimpresion_id = t2.id", "left");
|
|
|
|
return $builder;
|
|
}
|
|
}
|