Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel version update #678

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
composer.phar
composer.lock
.DS_Store
.DS_Store
.idea
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
}
],
"require": {
"illuminate/support": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.*|| 5.6.* || 5.7.*",
"illuminate/session": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.*|| 5.6.* || 5.7.*",
"illuminate/events": "5.1.* || 5.2.* || 5.3.* || 5.4.* || 5.5.*|| 5.6.* || 5.7.*"
"illuminate/support": "~6.0 || ~7.0 || ~8.0 || ~9.0 || ~10.0",
"illuminate/session": "~6.0 || ~7.0 || ~8.0 || ~9.0 || ~10.0",
"illuminate/events": "~6.0 || ~7.0 || ~8.0 || ~9.0 || ~10.0"
},
"require-dev": {
"phpunit/phpunit": "~5.0 || ~6.0 || ~7.0",
Expand Down
10 changes: 5 additions & 5 deletions src/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function add($id, $name = null, $qty = null, $price = null, array $option

$content->put($cartItem->rowId, $cartItem);

$this->events->fire('cart.added', $cartItem);
$this->events->dispatch('cart.added', $cartItem);

$this->session->put($this->instance, $content);

Expand Down Expand Up @@ -148,7 +148,7 @@ public function update($rowId, $qty)
$content->put($cartItem->rowId, $cartItem);
}

$this->events->fire('cart.updated', $cartItem);
$this->events->dispatch('cart.updated', $cartItem);

$this->session->put($this->instance, $content);

Expand All @@ -169,7 +169,7 @@ public function remove($rowId)

$content->pull($cartItem->rowId);

$this->events->fire('cart.removed', $cartItem);
$this->events->dispatch('cart.removed', $cartItem);

$this->session->put($this->instance, $content);
}
Expand Down Expand Up @@ -360,7 +360,7 @@ public function store($identifier)
'content' => serialize($content)
]);

$this->events->fire('cart.stored');
$this->events->dispatch('cart.stored');
}

/**
Expand Down Expand Up @@ -390,7 +390,7 @@ public function restore($identifier)
$content->put($cartItem->rowId, $cartItem);
}

$this->events->fire('cart.restored');
$this->events->dispatch('cart.restored');

$this->session->put($this->instance, $content);

Expand Down
29 changes: 15 additions & 14 deletions src/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Contracts\Support\Arrayable;
use Gloudemans\Shoppingcart\Contracts\Buyable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Arr;

class CartItem implements Arrayable, Jsonable
{
Expand Down Expand Up @@ -103,7 +104,7 @@ public function price($decimals = null, $decimalPoint = null, $thousandSeperator
{
return $this->numberFormat($this->price, $decimals, $decimalPoint, $thousandSeperator);
}

/**
* Returns the formatted price with TAX.
*
Expand All @@ -130,7 +131,7 @@ public function subtotal($decimals = null, $decimalPoint = null, $thousandSepera
{
return $this->numberFormat($this->subtotal, $decimals, $decimalPoint, $thousandSeperator);
}

/**
* Returns the formatted total.
* Total is price for whole CartItem with TAX
Expand All @@ -157,7 +158,7 @@ public function tax($decimals = null, $decimalPoint = null, $thousandSeperator =
{
return $this->numberFormat($this->tax, $decimals, $decimalPoint, $thousandSeperator);
}

/**
* Returns the formatted tax.
*
Expand Down Expand Up @@ -206,12 +207,12 @@ public function updateFromBuyable(Buyable $item)
*/
public function updateFromArray(array $attributes)
{
$this->id = array_get($attributes, 'id', $this->id);
$this->qty = array_get($attributes, 'qty', $this->qty);
$this->name = array_get($attributes, 'name', $this->name);
$this->price = array_get($attributes, 'price', $this->price);
$this->id = Arr::get($attributes, 'id', $this->id);
$this->qty = Arr::get($attributes, 'qty', $this->qty);
$this->name = Arr::get($attributes, 'name', $this->name);
$this->price = Arr::get($attributes, 'price', $this->price);
$this->priceTax = $this->price + $this->tax;
$this->options = new CartItemOptions(array_get($attributes, 'options', $this->options));
$this->options = new CartItemOptions(Arr::get($attributes, 'options', $this->options));

$this->rowId = $this->generateRowId($this->id, $this->options->all());
}
Expand All @@ -225,7 +226,7 @@ public function updateFromArray(array $attributes)
public function associate($model)
{
$this->associatedModel = is_string($model) ? $model : get_class($model);

return $this;
}

Expand All @@ -238,7 +239,7 @@ public function associate($model)
public function setTaxRate($taxRate)
{
$this->taxRate = $taxRate;

return $this;
}

Expand All @@ -257,19 +258,19 @@ public function __get($attribute)
if($attribute === 'priceTax') {
return $this->price + $this->tax;
}

if($attribute === 'subtotal') {
return $this->qty * $this->price;
}

if($attribute === 'total') {
return $this->qty * ($this->priceTax);
}

if($attribute === 'tax') {
return $this->price * ($this->taxRate / 100);
}

if($attribute === 'taxTotal') {
return $this->tax * $this->qty;
}
Expand Down Expand Up @@ -301,7 +302,7 @@ public static function fromBuyable(Buyable $item, array $options = [])
*/
public static function fromArray(array $attributes)
{
$options = array_get($attributes, 'options', []);
$options = Arr::get($attributes, 'options', []);

return new self($attributes['id'], $attributes['name'], $attributes['price'], $options);
}
Expand Down