Add the getItemIds in the Cart to get ids of items.
This commit is contained in:
+10
-3
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user