mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 13:51:44 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dfd0ce761 | ||
|
|
a3161888aa |
@@ -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:
|
||||
|
||||
+11
-11
@@ -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",
|
||||
@@ -38,10 +38,10 @@
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"psr-4": {
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"extra": {
|
||||
"laravel": {
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user