mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 23:51:25 +00:00
Codestyle
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Gloudemans\Shoppingcart;
|
|||||||
|
|
||||||
trait CanBeBought
|
trait CanBeBought
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the identifier of the Buyable item.
|
* Get the identifier of the Buyable item.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ class Cart
|
|||||||
|
|
||||||
if ($cartItem->qty <= 0) {
|
if ($cartItem->qty <= 0) {
|
||||||
$this->remove($cartItem->rowId);
|
$this->remove($cartItem->rowId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
$content->put($cartItem->rowId, $cartItem);
|
$content->put($cartItem->rowId, $cartItem);
|
||||||
|
|||||||
@@ -255,8 +255,9 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
*/
|
*/
|
||||||
public function setQuantity($qty)
|
public function setQuantity($qty)
|
||||||
{
|
{
|
||||||
if(empty($qty) || ! is_numeric($qty))
|
if (empty($qty) || !is_numeric($qty)) {
|
||||||
throw new \InvalidArgumentException('Please supply a valid quantity.');
|
throw new \InvalidArgumentException('Please supply a valid quantity.');
|
||||||
|
}
|
||||||
|
|
||||||
$this->qty = $qty;
|
$this->qty = $qty;
|
||||||
}
|
}
|
||||||
@@ -351,8 +352,7 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
return $this->{$attribute};
|
return $this->{$attribute};
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($attribute)
|
switch ($attribute) {
|
||||||
{
|
|
||||||
case 'discount':
|
case 'discount':
|
||||||
return $this->price * ($this->discountRate / 100);
|
return $this->price * ($this->discountRate / 100);
|
||||||
case 'priceTarget':
|
case 'priceTarget':
|
||||||
@@ -373,12 +373,13 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
return $this->weight * $this->qty;
|
return $this->weight * $this->qty;
|
||||||
|
|
||||||
case 'model':
|
case 'model':
|
||||||
if (isset($this->associatedModel))
|
if (isset($this->associatedModel)) {
|
||||||
return with(new $this->associatedModel)->find($this->id);
|
return with(new $this->associatedModel)->find($this->id);
|
||||||
return null;
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +457,7 @@ class CartItem implements Arrayable, Jsonable
|
|||||||
'options' => $this->options->toArray(),
|
'options' => $this->options->toArray(),
|
||||||
'discount' => $this->discount,
|
'discount' => $this->discount,
|
||||||
'tax' => $this->tax,
|
'tax' => $this->tax,
|
||||||
'subtotal' => $this->subtotal
|
'subtotal' => $this->subtotal,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user