Refactor the Cart model.

Moved the dropItems above its first usage.
This commit is contained in:
2023-06-18 18:42:40 +03:00
parent d90f017cbe
commit 3fe7287e06
+10 -7
View File
@@ -47,6 +47,10 @@ class Cart extends Model
return count($this->getItemIds());
}
public function dropItems() {
$this->items()->detach();
}
public function setCity(City $city)
{
if($this->city_id == $city->id)
@@ -78,20 +82,19 @@ class Cart extends Model
$this->items()->sync($item);
}
public function addItems(array $items) {
public function addItems(array $items)
{
$this->items()->sync($items);
}
public function removeItem(BigInteger $item) {
public function removeItem(BigInteger $item)
{
$this->items()->sync($item);
}
public function removeItems(array $items) {
public function removeItems(array $items)
{
$this->items()->sync($items);
}
public function dropItems() {
$this->items()->detach();
}
}