diff --git a/app/Models/Cart.php b/app/Models/Cart.php index f5cc164..b5ac2f1 100644 --- a/app/Models/Cart.php +++ b/app/Models/Cart.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; use App\Models\City; +use Brick\Math\BigInteger; class Cart extends Model { @@ -51,6 +52,22 @@ class Cart extends Model $this->save(); } + public function addItem(BigInteger $item) { + $this->items()->sync($item); + } + + public function addItems(array $items) { + $this->items()->sync($items); + } + + public function removeItem(BigInteger $item) { + $this->items()->sync($item); + } + + public function removeItems(array $items) { + $this->items()->sync($items); + } + public function dropItems() { $this->items()->detach(); }