mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-11 18:54:33 +00:00
Add validation and exception for weight to CartItem Constructor
This commit is contained in:
@@ -97,6 +97,9 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
if (strlen($price) < 0 || !is_numeric($price)) {
|
if (strlen($price) < 0 || !is_numeric($price)) {
|
||||||
throw new \InvalidArgumentException('Please supply a valid price.');
|
throw new \InvalidArgumentException('Please supply a valid price.');
|
||||||
}
|
}
|
||||||
|
if (strlen($weight) < 0 || !is_numeric($weight)) {
|
||||||
|
throw new \InvalidArgumentException('Please supply a valid weight.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
|
|||||||
Reference in New Issue
Block a user