From 78c197549de2769bdc047f2004cce97bcc212c02 Mon Sep 17 00:00:00 2001 From: KKlochko Date: Tue, 20 Jun 2023 20:13:44 +0300 Subject: [PATCH] Add a resource and a collection for show CartItem. --- .../Resources/API/v2/CartItemCollection.php | 19 +++++++++++++ .../Resources/API/v2/CartItemResource.php | 28 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 app/Http/Resources/API/v2/CartItemCollection.php create mode 100644 app/Http/Resources/API/v2/CartItemResource.php diff --git a/app/Http/Resources/API/v2/CartItemCollection.php b/app/Http/Resources/API/v2/CartItemCollection.php new file mode 100644 index 0000000..ad08165 --- /dev/null +++ b/app/Http/Resources/API/v2/CartItemCollection.php @@ -0,0 +1,19 @@ + + */ + public function toArray(Request $request): array + { + return parent::toArray($request); + } +} diff --git a/app/Http/Resources/API/v2/CartItemResource.php b/app/Http/Resources/API/v2/CartItemResource.php new file mode 100644 index 0000000..7d3356a --- /dev/null +++ b/app/Http/Resources/API/v2/CartItemResource.php @@ -0,0 +1,28 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'uuid' => $this->uuid, + 'name' => $this->name, + 'url' => $this->url, + 'description' => $this->description, + 'price' => $this->price, + 'image' => $this->image, + 'count' => $this->count, + ]; + } +}