Arreglos en resource

This commit is contained in:
Alejandro Tasistro 2025-03-18 19:45:06 -03:00
parent 354079519a
commit 56eb59ddeb

View file

@ -14,17 +14,16 @@ class SubpedidoResource extends JsonResource
*/ */
public function toArray($request) public function toArray($request)
{ {
$total = $this->total();
return [ return [
'id' => $this->id, 'id' => $this->id,
'nombre' => $this->nombre, 'nombre' => $this->nombre,
'grupo_de_compra' => $this->grupoDeCompra, 'grupo_de_compra' => $this->grupoDeCompra,
'productos' => $this->productos, 'productos' => $this->productos,
'aprobado' => (bool) $this->aprobado, 'aprobado' => (bool) $this->aprobado,
'total' => $total, 'total' => $this->total(),
'total_transporte' => $this->totalTransporte(), 'total_transporte' => $this->totalTransporte(),
'cantidad_transporte' => number_format($this->cantidadTransporte(),0), 'cantidad_transporte' => number_format($this->cantidadTransporte(),0),
'total_menos_devoluciones' => $total - $this->devoluciones_total, 'total_sin_devoluciones' => $this->totalSinDevoluciones(),
'devoluciones_total' => $this->devoluciones_total, 'devoluciones_total' => $this->devoluciones_total,
'devoluciones_notas' => $this->devoluciones_notas 'devoluciones_notas' => $this->devoluciones_notas
]; ];