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

This commit is contained in:
2023-06-22 10:58:21 +03:00
parent 2b8d6e3062
commit 6c13fe7d7d
+14
View File
@@ -56,6 +56,20 @@ class Cart extends Model
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
{
return $this->items()->pluck('item_id')->toArray();