Make CartItem implement Arrayable contract

This commit is contained in:
Rob Gloudemans
2016-06-15 10:15:03 +02:00
parent 13fe150b77
commit 6c82e21626

View File

@@ -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
];
}
}