mirror of
https://github.com/wearepixel/laravel-cart.git
synced 2026-11-14 22:01:48 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dfd0ce761 | ||
|
|
a3161888aa |
@@ -13,7 +13,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
matrix:
|
matrix:
|
||||||
php: ['8.2', '8.3', '8.4']
|
php: ['8.3', '8.4', '8.5']
|
||||||
stability: [prefer-stable]
|
stability: [prefer-stable]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
|||||||
+11
-11
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "joelwmale/laravel-cart",
|
"name": "joelwmale/laravel-cart",
|
||||||
"version": "1.2.1",
|
"version": "2.0.0",
|
||||||
"description": "A cart implementation for Laravel",
|
"description": "A cart implementation for Laravel",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"laravel",
|
"laravel",
|
||||||
@@ -19,12 +19,12 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2",
|
"php": ">=8.3",
|
||||||
"illuminate/support": "^10.0|^11.0|^12.0",
|
"illuminate/support": "^11.0|^12.0|^13.0",
|
||||||
"illuminate/auth": "^10.0|^11.0|^12.0",
|
"illuminate/auth": "^11.0|^12.0|^13.0",
|
||||||
"illuminate/container": "^10.0|^11.0|^12.0",
|
"illuminate/container": "^11.0|^12.0|^13.0",
|
||||||
"illuminate/database": "^10.0|^11.0|^12.0",
|
"illuminate/database": "^11.0|^12.0|^13.0",
|
||||||
"illuminate/validation": "^10.0|^11.0|^12.0"
|
"illuminate/validation": "^11.0|^12.0|^13.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mockery/mockery": "^1.6",
|
"mockery/mockery": "^1.6",
|
||||||
@@ -38,10 +38,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload-dev": {
|
"autoload-dev": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"Tests\\": "tests/"
|
"Tests\\": "tests/"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"extra": {
|
"extra": {
|
||||||
"laravel": {
|
"laravel": {
|
||||||
|
|||||||
@@ -165,9 +165,31 @@ public function add(
|
|||||||
|
|
||||||
$this->currentItemId = $id;
|
$this->currentItemId = $id;
|
||||||
|
|
||||||
|
// clean up any incomplete items
|
||||||
|
$this->removeInvalidItems();
|
||||||
|
|
||||||
return $this;
|
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
|
* Update a cart item with whatever data is passed in
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user