feature/columna-totales #4

Open
atasistro wants to merge 46 commits from feature/columna-totales into master
Showing only changes of commit 830002b4cf - Show all commits

View file

@ -96,4 +96,24 @@ class Pedido extends Model
function totalChismosa() : float {
return $this->total() + $this->totalTransporte();
}
function toggleConfirm() : bool {
$this->confirmed = !$this->confirmed;
$this->save();
return $this->confirmed;
}
function agregarProducto(Producto $producto, int $cantidad) {
$productoEnChismosa = $this->productos()->where('id', $producto->id)->first();
if ($productoEnChismosa) {
$productoEnChismosa->pivot->cantidad += $cantidad;
$productoEnChismosa->save();
} else {
$this->productos()->attach($producto, ['cantidad' => $cantidad]);
}
}
function quitarProducto(Producto $producto) {
$this->productos()->detach($producto);
}
}