ot relations

This commit is contained in:
amazuecos
2024-12-11 10:19:55 +01:00
parent f70f6a0929
commit 71157bfda5
3 changed files with 39 additions and 9 deletions

View File

@ -21,33 +21,37 @@ class OrdenTrabajoTable extends Migration
"user_created_id" => [
"type" => "INT",
"constraint" => 10,
"comment" => "Usuario que ha pasado el pedido a producción",
],
"user_update_id" => [
"type" => "INT",
"constraint" => 10,
"comment" => "Usuario que ha actualizado la orden de trabajo",
],
"maquina_orden_negro_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
"null" => true,
"comment" => "Maquina para impresion en negro",
],
"maquina_orden_color_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
"null" => true,
"comment" => "Maquina para impresion en color",
],
"maquina_orden_portada_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
"null" => true,
"comment" => "Maquina para impresion portada",
],
"maquina_orden_cubierta_id" => [
"type" => "INT",
"constraint" => 10,
"null" => true
"null" => true,
"comment" => "Maquina para impresion cubierta",
],
"negro_forma_id" => [
"type" => "INT",

View File

@ -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;
}
}

View File

@ -2,7 +2,7 @@
namespace App\Models\OrdenTrabajo;
use App\Entities\Presupuestos\OrdenTrabajoEntity;
use App\Entities\Produccion\OrdenTrabajoEntity;
use CodeIgniter\Database\BaseBuilder;
use CodeIgniter\Model;
class OrdenTrabajoModel extends Model