mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
ot relations
This commit is contained in:
@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Presupuestos;
|
||||
|
||||
use App\Models\Presupuestos\PresupuestoLineaModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
@ -78,7 +81,7 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
"total_margen_envios" => null,
|
||||
"total_costes" => null,
|
||||
"total_margenes" => null,
|
||||
"total_antes_descuento" => null,
|
||||
"total_antes_descuento" => null,
|
||||
"total_descuento" => null,
|
||||
"total_descuentoPercent" => null,
|
||||
"total_precio_unidad" => null,
|
||||
@ -165,4 +168,27 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity
|
||||
'paginasCuadernillo' => "int",
|
||||
'lomo_redondo' => "boolean",
|
||||
];
|
||||
/**
|
||||
* Devuelve la entity con un campo `presupuesto_lineas` con las lineas de presupuesto asociadas
|
||||
*
|
||||
* @return this
|
||||
*/
|
||||
public function withPresupuestoLineas()
|
||||
{
|
||||
$this->attributes["presupuesto_lineas"] = $this->presupuestoLineas();
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Obtiene las lineas de presupuesto del actual presupuesto
|
||||
*
|
||||
* @return array<PresupuestoLineaEntity>
|
||||
*/
|
||||
public function presupuestoLineas(): array
|
||||
{
|
||||
$model = model(PresupuestoLineaModel::class);
|
||||
|
||||
$q = $model->where('presupuesto_id', $this->attributes["id"])->findAll();
|
||||
|
||||
return $q;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user