Replaced array_get with Arr::get as the helper method has been removed in 6.0

This commit is contained in:
Dan Tomlinson
2019-09-06 16:49:42 +01:00
parent bcc43079e3
commit 7401f5bbb1

View File

@@ -5,6 +5,7 @@ namespace Gloudemans\Shoppingcart;
use Gloudemans\Shoppingcart\Contracts\Buyable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Arr;
class CartItem implements Arrayable, Jsonable
{
@@ -289,13 +290,13 @@ class CartItem implements Arrayable, Jsonable
*/
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->weight = array_get($attributes, 'weight', $this->weight);
$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->weight = Arr::get($attributes, 'weight', $this->weight);
$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());
}
@@ -412,7 +413,7 @@ class CartItem implements Arrayable, Jsonable
*/
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'], $attributes['weight'], $options);
}