null, "total_precio" => null, "total_tirada" => null, "estado" => null, "inaplazable" => null, "user_created_id" => null, "user_updated_id" => null, "user_validated_id" => null, "fecha_entrega_real" => null, "fecha_impresion" => null, "fecha_encuadernado" => null, "fecha_entrega_externo" => null, "fecha_entrega_real_change_user_id" => null, "fecha_impresion_change_user_id" => null, "fecha_encuadernado_change_user_id" => null, "fecha_entrega_change_externo_user_id" => null, "inaplazable_change_user_id" => null, "created_at" => null, "updated_at" => null, "validated_at" => null, ]; protected $casts = [ "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 ubicacion(): ?UbicacionesEntity { $lineas = $this->lineas(); $ubicacion = null; foreach ($lineas as $key => $linea) { $ubicacion = $linea->ubicacion(); } return $ubicacion; } 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(); } public function cliente() : ?ClienteEntity { $m = model(ClienteModel::class); $pl = model(PedidoLineaModel::class); $pm = model(PresupuestoModel::class); $pedido_linea = $pl->where('pedido_id',$this->attributes["id"])->first(); $pre = $pm->find($pedido_linea->presupuesto_id); return $m->find($pre->cliente_id); } }