Add the method to get cart items as the JSON array.

main
KKlochko 2 years ago
parent 2b8d6e3062
commit 6c13fe7d7d

@ -56,6 +56,20 @@ class Cart extends Model
return $item; return $item;
} }
public function getItemJSON()
{
$items = $this->items;
$itemJSON = [];
foreach($items as $item)
array_push($itemJSON, [
'id' =>$item->uuid,
'count'=> $item->count
]);
return $itemJSON;
}
public function getItemIds(): array public function getItemIds(): array
{ {
return $this->items()->pluck('item_id')->toArray(); return $this->items()->pluck('item_id')->toArray();

Loading…
Cancel
Save