mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
ots
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
<?php
|
||||
namespace App\Entities\Pedidos;
|
||||
|
||||
use App\Entities\Presupuestos\PresupuestoEntity;
|
||||
use App\Entities\Produccion\OrdenTrabajoEntity;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
use App\Models\Pedidos\PedidoLineaModel;
|
||||
use App\Models\Presupuestos\PresupuestoModel;
|
||||
use CodeIgniter\Entity;
|
||||
|
||||
class PedidoEntity extends \CodeIgniter\Entity\Entity
|
||||
@ -27,4 +32,35 @@ class PedidoEntity extends \CodeIgniter\Entity\Entity
|
||||
"total_precio" => "float",
|
||||
"total_tirada" => "float",
|
||||
];
|
||||
/**
|
||||
* Devuelve la entidad `PedidoEntity` con sus relaciones
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function withAllRelations() : self
|
||||
{
|
||||
$this->attributes["pedido_lineas"] = $this->lineas();
|
||||
$this->attributes["presupuesto"] = $this->presupuesto();
|
||||
|
||||
return $this;
|
||||
}
|
||||
public function lineas(): array
|
||||
{
|
||||
$q = model(PedidoLineaModel::class);
|
||||
$q->where("pedido_id",$this->attributes["id"]);
|
||||
return $q->findAll();
|
||||
}
|
||||
public function presupuesto() : PresupuestoEntity
|
||||
{
|
||||
$q = model(PedidoLineaModel::class);
|
||||
$p = model(PresupuestoModel::class);
|
||||
$presupuesto_id = $q->where("pedido_id",$this->attributes["id"])->first()->presupuesto_id;
|
||||
return $p->find($presupuesto_id);
|
||||
}
|
||||
public function orden_trabajo() : ?OrdenTrabajoEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoModel::class);
|
||||
return $m->where("pedido_id",$this->attributes["id"])->first();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user