pedi2/app/Http/Resources/SubpedidoResource.php
2025-03-17 17:02:49 -03:00

32 lines
984 B
PHP

<?php
namespace App\Http\Resources;
use Illuminate\Http\Resources\Json\JsonResource;
class SubpedidoResource extends JsonResource
{
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function toArray($request)
{
$total = $this->total();
return [
'id' => $this->id,
'nombre' => $this->nombre,
'grupo_de_compra' => $this->grupoDeCompra,
'productos' => $this->productos,
'aprobado' => (bool) $this->aprobado,
'total' => $total,
'total_transporte' => $this->totalTransporte(),
'cantidad_transporte' => number_format($this->cantidadTransporte(),0),
'total_menos_devoluciones' => $total - $this->devoluciones_total,
'devoluciones_total' => $this->devoluciones_total,
'devoluciones_notas' => $this->devoluciones_notas
];
}
}