This commit is contained in:
Juan Pablo Vial
2025-08-22 09:28:53 -04:00
parent 78222eb9f1
commit 454ba41d9c
26 changed files with 1036 additions and 135 deletions

View File

@ -68,7 +68,7 @@ class Reservation extends Common\Ideal\Model
public function addUnit(Model\Venta\Unidad $unit, float $value): self
{
if (($i = $this->findUnit($unit->id)) !== null) {
$this->units[$i]['value'] = $value;
$this->units[$i]->value = $value;
return $this;
}
$this->units[] = (object) [
@ -88,12 +88,7 @@ class Reservation extends Common\Ideal\Model
}
public function findUnit(int $unit_id): ?int
{
foreach ($this->units as $idx => $unit) {
if ($unit['unit']->id == $unit_id) {
return $idx;
}
}
return null;
return array_find_key($this->units, fn($unit) => $unit->unit->id == $unit_id);
}
public function hasUnit(int $unit_id): bool
{