Calculando total por producto
This commit is contained in:
parent
44465c2783
commit
8799446e57
1 changed files with 5 additions and 1 deletions
|
@ -15,11 +15,15 @@ class SubpedidoResource extends JsonResource
|
||||||
*/
|
*/
|
||||||
public function toArray($request): array
|
public function toArray($request): array
|
||||||
{
|
{
|
||||||
|
$productos = $this->productos;
|
||||||
|
foreach ($productos as $producto) {
|
||||||
|
$producto['pivot']['total'] = number_format($producto->pivot->cantidad * $producto->precio, 2);
|
||||||
|
}
|
||||||
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' => $productos,
|
||||||
'aprobado' => (bool) $this->aprobado,
|
'aprobado' => (bool) $this->aprobado,
|
||||||
'total' => number_format($this->total(),2),
|
'total' => number_format($this->total(),2),
|
||||||
'total_transporte' => number_format($this->totalTransporte()),
|
'total_transporte' => number_format($this->totalTransporte()),
|
||||||
|
|
Loading…
Add table
Reference in a new issue