From 9f5a84a150c497f8fc8eae5dd9f24d923e258cd1 Mon Sep 17 00:00:00 2001 From: rachana chaturvedi Date: Tue, 18 Jul 2023 10:19:41 +0530 Subject: [PATCH 1/4] store user validation fixed --- .../Controllers/V1/Admin/Setting/UserController.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Http/Controllers/V1/Admin/Setting/UserController.php b/src/Http/Controllers/V1/Admin/Setting/UserController.php index e097b0e2..cd31c5e5 100755 --- a/src/Http/Controllers/V1/Admin/Setting/UserController.php +++ b/src/Http/Controllers/V1/Admin/Setting/UserController.php @@ -37,6 +37,12 @@ public function resource() */ public function store(UserForm $request) { + $request->validate([ + 'name' => 'required', + 'email' => 'required|email', + 'role_id' => 'required|integer', + ]); + $data = $request->all(); if (isset($data['password']) && $data['password']) { @@ -107,6 +113,10 @@ public function destroy($id) */ private function prepareUserData(UserForm $request, $id) { + $request->validate([ + 'role_id' => 'integer', + ]); + $data = $request->validated(); $user = $this->getRepositoryInstance()->findOrFail($id); From 821be7c97f402f3ff9eb57ebdc521f886a88ac24 Mon Sep 17 00:00:00 2001 From: rachana chaturvedi Date: Thu, 20 Jul 2023 20:33:15 +0530 Subject: [PATCH 2/4] minor changes in tax and slider controller --- .../V1/Admin/Catalog/ProductController.php | 1 + .../Controllers/V1/Admin/Setting/SliderController.php | 9 ++++----- .../V1/Admin/Setting/TaxCategoryController.php | 6 ++---- .../Controllers/V1/Admin/Setting/UserController.php | 11 ----------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/src/Http/Controllers/V1/Admin/Catalog/ProductController.php b/src/Http/Controllers/V1/Admin/Catalog/ProductController.php index 54952568..293d3370 100755 --- a/src/Http/Controllers/V1/Admin/Catalog/ProductController.php +++ b/src/Http/Controllers/V1/Admin/Catalog/ProductController.php @@ -178,6 +178,7 @@ public function massUpdate(MassUpdateRequest $request) 'channel' => null, 'locale' => null, 'status' => $request->update_value, + 'booking' => $request->booking ], $id); Event::dispatch('catalog.product.update.after', $product); diff --git a/src/Http/Controllers/V1/Admin/Setting/SliderController.php b/src/Http/Controllers/V1/Admin/Setting/SliderController.php index 37c85be4..45926bcc 100755 --- a/src/Http/Controllers/V1/Admin/Setting/SliderController.php +++ b/src/Http/Controllers/V1/Admin/Setting/SliderController.php @@ -51,7 +51,7 @@ public function store(Request $request) $data['locale'] = implode(',', $data['locale']); } - $result = $this->getRepositoryInstance()->save($data); + $result = $this->getRepositoryInstance()->create($data); if ($result) { $slider = $this->getRepositoryInstance()->latest('id')->first(); @@ -96,10 +96,9 @@ public function update(Request $request, $id) return response([ 'message' => __('rest-api::app.common-response.error.something-went-wrong'), ], 500); - } - - $result = $this->getRepositoryInstance()->updateItem($data, $id); - + } + + $result = $this->getRepositoryInstance()->update($data, $id); if ($result) { return response([ 'data' => $this->getRepositoryInstance()->find($id), diff --git a/src/Http/Controllers/V1/Admin/Setting/TaxCategoryController.php b/src/Http/Controllers/V1/Admin/Setting/TaxCategoryController.php index d052bb56..1f034451 100755 --- a/src/Http/Controllers/V1/Admin/Setting/TaxCategoryController.php +++ b/src/Http/Controllers/V1/Admin/Setting/TaxCategoryController.php @@ -47,7 +47,7 @@ public function store(Request $request) $taxCategory = $this->getRepositoryInstance()->create($data); - $this->getRepositoryInstance()->attachOrDetach($taxCategory, $data['taxrates']); + $taxCategory->tax_rates()->sync($data['taxrates']); return response([ 'data' => new TaxCategoryResource($this->getRepositoryInstance()->find($taxCategory->id)), @@ -75,9 +75,7 @@ public function update(Request $request, $id) $taxCategory = $this->getRepositoryInstance()->update($data, $id); - $taxRates = $data['taxrates']; - - $this->getRepositoryInstance()->attachOrDetach($taxCategory, $taxRates); + $taxCategory->tax_rates()->sync($data['taxrates']); return response([ 'data' => new TaxCategoryResource($this->getRepositoryInstance()->find($taxCategory->id)), diff --git a/src/Http/Controllers/V1/Admin/Setting/UserController.php b/src/Http/Controllers/V1/Admin/Setting/UserController.php index cd31c5e5..09a99577 100755 --- a/src/Http/Controllers/V1/Admin/Setting/UserController.php +++ b/src/Http/Controllers/V1/Admin/Setting/UserController.php @@ -37,14 +37,7 @@ public function resource() */ public function store(UserForm $request) { - $request->validate([ - 'name' => 'required', - 'email' => 'required|email', - 'role_id' => 'required|integer', - ]); - $data = $request->all(); - if (isset($data['password']) && $data['password']) { $data['password'] = bcrypt($data['password']); $data['api_token'] = Str::random(80); @@ -113,10 +106,6 @@ public function destroy($id) */ private function prepareUserData(UserForm $request, $id) { - $request->validate([ - 'role_id' => 'integer', - ]); - $data = $request->validated(); $user = $this->getRepositoryInstance()->findOrFail($id); From c63b002dac760dfb2846af048c00c8a1acc758b0 Mon Sep 17 00:00:00 2001 From: rachana chaturvedi Date: Fri, 21 Jul 2023 19:25:11 +0530 Subject: [PATCH 3/4] minor functionality changes --- src/Http/Resources/V1/Shop/Catalog/ProductResource.php | 8 ++++---- src/Routes/V1/Shop/customer-routes.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Http/Resources/V1/Shop/Catalog/ProductResource.php b/src/Http/Resources/V1/Shop/Catalog/ProductResource.php index dc45a792..43beae67 100644 --- a/src/Http/Resources/V1/Shop/Catalog/ProductResource.php +++ b/src/Http/Resources/V1/Shop/Catalog/ProductResource.php @@ -102,19 +102,19 @@ private function specialPriceInfo() return [ 'special_price' => $this->when( - $productTypeInstance ->haveSpecialPrice(), + $productTypeInstance ->haveDiscount(), core()->convertPrice($productTypeInstance->getMinimalPrice()) ), 'formatted_special_price' => $this->when( - $productTypeInstance->haveSpecialPrice(), + $productTypeInstance->haveDiscount(), core()->currency($productTypeInstance->getMinimalPrice()) ), 'regular_price' => $this->when( - $productTypeInstance->haveSpecialPrice(), + $productTypeInstance->haveDiscount(), data_get($productTypeInstance->getProductPrices(), 'regular_price.price') ), 'formatted_regular_price' => $this->when( - $productTypeInstance->haveSpecialPrice(), + $productTypeInstance->haveDiscount(), data_get($productTypeInstance->getProductPrices(), 'regular_price.formated_price') ), ]; diff --git a/src/Routes/V1/Shop/customer-routes.php b/src/Routes/V1/Shop/customer-routes.php index 101a0e40..b49f15ae 100644 --- a/src/Routes/V1/Shop/customer-routes.php +++ b/src/Routes/V1/Shop/customer-routes.php @@ -33,12 +33,12 @@ /** * Customer address routes. */ - Route::get('customer/addresses', [AddressController::class, 'index']); + Route::get('customer/addresses', [AddressController::class, 'allResources']); - Route::post('customer/addresses', [AddressController::class, 'store']); - - Route::get('customer/addresses/{id}', [AddressController::class, 'show']); + Route::get('customer/addresses/{id}', [AddressController::class, 'getResource']); + Route::post('customer/addresses', [AddressController::class, 'store']); + Route::put('customer/addresses/{id}', [AddressController::class, 'update']); Route::delete('customer/addresses/{id}', [AddressController::class, 'destroy']); From 90ff304fdcc6678d5252e81474162fa1a8d0b025 Mon Sep 17 00:00:00 2001 From: rachana chaturvedi Date: Fri, 21 Jul 2023 19:56:45 +0530 Subject: [PATCH 4/4] minor changes --- src/Http/Controllers/V1/Admin/Catalog/ProductController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Http/Controllers/V1/Admin/Catalog/ProductController.php b/src/Http/Controllers/V1/Admin/Catalog/ProductController.php index 293d3370..54952568 100755 --- a/src/Http/Controllers/V1/Admin/Catalog/ProductController.php +++ b/src/Http/Controllers/V1/Admin/Catalog/ProductController.php @@ -178,7 +178,6 @@ public function massUpdate(MassUpdateRequest $request) 'channel' => null, 'locale' => null, 'status' => $request->update_value, - 'booking' => $request->booking ], $id); Event::dispatch('catalog.product.update.after', $product);