mirror of
https://github.com/kevin-DL/LaravelShoppingcart.git
synced 2026-01-23 07:31:31 +00:00
Make CartItem implement Arrayable contract
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace Gloudemans\Shoppingcart;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Gloudemans\Shoppingcart\Contracts\Buyable;
|
||||
|
||||
class CartItem
|
||||
class CartItem implements Arrayable
|
||||
{
|
||||
/**
|
||||
* The rowID of the cart item.
|
||||
@@ -268,4 +269,22 @@ class CartItem
|
||||
|
||||
return md5($id . serialize($options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instance as an array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
'rowId' => $this->rowId,
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'qty' => $this->qty,
|
||||
'price' => $this->price,
|
||||
'tax' => $this->tax,
|
||||
'subtotal' => $this->subtotal
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user