mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
ots
This commit is contained in:
88
ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php
Normal file
88
ci4/app/Entities/Produccion/OrdenTrabajoTareaEntity.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entities\Produccion;
|
||||
|
||||
use App\Entities\Configuracion\Maquina;
|
||||
use App\Entities\Presupuestos\PresupuestoLineaEntity;
|
||||
use App\Models\Configuracion\MaquinaModel;
|
||||
use App\Models\OrdenTrabajo\OrdenTrabajoModel;
|
||||
use App\Models\Presupuestos\PresupuestoLineaModel;
|
||||
use CodeIgniter\Entity\Entity;
|
||||
|
||||
class OrdenTrabajoTareaEntity extends Entity
|
||||
{
|
||||
protected $attributes = [
|
||||
"id" => null,
|
||||
"orden_trabajo_id" => null,
|
||||
"presupuesto_linea_id" => null,
|
||||
"nombre" => null,
|
||||
"orden" => null,
|
||||
"maquina_id" => null,
|
||||
"imposicion_id" => null,
|
||||
"tiempo_estimado" => null,
|
||||
"tiempo_real" => null,
|
||||
];
|
||||
protected $datamap = [];
|
||||
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
|
||||
protected $casts = [
|
||||
"id" => "integer",
|
||||
"orden_trabajo_id" => "integer",
|
||||
"presupuesto_linea_id" => "?integer",
|
||||
"nombre" => "string",
|
||||
"orden" => "integer",
|
||||
"maquina_id" => "?integer",
|
||||
"imposicion_id" => "?integer",
|
||||
"tiempo_estimado" => "?float",
|
||||
"tiempo_real" => "?float"
|
||||
];
|
||||
|
||||
/**
|
||||
* Orden de trabajo de la tarea
|
||||
*
|
||||
* @return OrdenTrabajoEntity
|
||||
*/
|
||||
public function orden_trabajo() : OrdenTrabajoEntity
|
||||
{
|
||||
$m = model(OrdenTrabajoModel::class);
|
||||
return $m->find($this->attributes["orden_trabajo_id"]);
|
||||
}
|
||||
/**
|
||||
* Tarea orden de trabajo con orden de trabajo
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function withOrdenTrabajo() : self
|
||||
{
|
||||
$this->attributes["orden_trabajo"] = $this->orden_trabajo();
|
||||
return $this;
|
||||
}
|
||||
/**
|
||||
* Devuelve la maquina actual de esta tarea
|
||||
*
|
||||
* @return Maquina
|
||||
*/
|
||||
public function maquina_actual() : Maquina
|
||||
{
|
||||
$m = model(MaquinaModel::class);
|
||||
return $m->find($this->attributes["maquina_id"]);
|
||||
}
|
||||
/**
|
||||
* Devuelve el presupuesto linea origen de esta tarea
|
||||
*
|
||||
* @return PresupuestoLineaEntity
|
||||
*/
|
||||
public function presupuesto_linea() : PresupuestoLineaEntity
|
||||
{
|
||||
$m = model(PresupuestoLineaModel::class);
|
||||
return $m->find($this->attributes["presupuesto_linea_id"]);
|
||||
}
|
||||
/**
|
||||
* Devuelve la maquina original del presupuesto linea
|
||||
*
|
||||
* @return Maquina
|
||||
*/
|
||||
public function maquina_presupuesto_linea() : Maquina
|
||||
{
|
||||
return $this->presupuesto_linea()->maquina();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user