diff --git a/src/CartItem.php b/src/CartItem.php index 1ef6cbe..42ed74d 100644 --- a/src/CartItem.php +++ b/src/CartItem.php @@ -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 + ]; + } } \ No newline at end of file