Compare commits

..
2 Commits
3 changed files with 34 additions and 12 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: ['8.2', '8.3', '8.4']
php: ['8.3', '8.4', '8.5']
stability: [prefer-stable]
steps:
+7 -7
View File
@@ -1,6 +1,6 @@
{
"name": "joelwmale/laravel-cart",
"version": "1.2.1",
"version": "2.0.0",
"description": "A cart implementation for Laravel",
"keywords": [
"laravel",
@@ -19,12 +19,12 @@
}
],
"require": {
"php": ">=8.2",
"illuminate/support": "^10.0|^11.0|^12.0",
"illuminate/auth": "^10.0|^11.0|^12.0",
"illuminate/container": "^10.0|^11.0|^12.0",
"illuminate/database": "^10.0|^11.0|^12.0",
"illuminate/validation": "^10.0|^11.0|^12.0"
"php": ">=8.3",
"illuminate/support": "^11.0|^12.0|^13.0",
"illuminate/auth": "^11.0|^12.0|^13.0",
"illuminate/container": "^11.0|^12.0|^13.0",
"illuminate/database": "^11.0|^12.0|^13.0",
"illuminate/validation": "^11.0|^12.0|^13.0"
},
"require-dev": {
"mockery/mockery": "^1.6",
+22
View File
@@ -165,9 +165,31 @@ public function add(
$this->currentItemId = $id;
// clean up any incomplete items
$this->removeInvalidItems();
return $this;
}
/**
* Remove any incomplete items
*/
public function removeInvalidItems(): bool
{
$carts = $this->getContent();
foreach ($carts as $index => $cart) {
if (! (isset($cart['id'], $cart['name'], $cart['quantity']))) {
// remove item
$this->remove($index);
}
}
return true;
}
/**
* Update a cart item with whatever data is passed in
*/