diff --git a/app/Models/Cart.php b/app/Models/Cart.php index c591733..271e173 100644 --- a/app/Models/Cart.php +++ b/app/Models/Cart.php @@ -37,11 +37,18 @@ class Cart extends Model return $this->belongsToMany(Item::class, 'carts_items', 'cart_id', 'item_id'); } - public function isEmpty() { - return count($this->items()->pluck('item_id')->toArray()); + public function getItemIds(): array + { + return $this->items()->pluck('item_id')->toArray(); } - public function setCity(City $city) { + public function isEmpty() + { + return count($this->getItemIds()); + } + + public function setCity(City $city) + { if($this->city_id == $city->id) return;