From de74446326a8670b5f22e3f4c165295abf586dc6 Mon Sep 17 00:00:00 2001 From: Steve <34465153+xxl4@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:54:02 +0800 Subject: [PATCH] fix support sort and rating --- .../Controllers/Customers/ReviewController.php | 13 ++++++++++++- .../Api/V1/Admin/Customers/ReviewController.php | 6 ++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Docs/V1/Admin/Controllers/Customers/ReviewController.php b/src/Docs/V1/Admin/Controllers/Customers/ReviewController.php index 794d9cf..79531fd 100644 --- a/src/Docs/V1/Admin/Controllers/Customers/ReviewController.php +++ b/src/Docs/V1/Admin/Controllers/Customers/ReviewController.php @@ -167,7 +167,18 @@ public function get() * example="approved", * enum={"pending", "approved", "disapproved"} * ), - * required={"status"} + * @OA\Property( + * property="rating", + * description="Review's rating", + * type="integer", + * example="5" + * ), + * @OA\Property( + * property="sort", + * description="Review's sort", + * type="integer", + * example="1" + * ), * ) * ) * ), diff --git a/src/Http/Controllers/Api/V1/Admin/Customers/ReviewController.php b/src/Http/Controllers/Api/V1/Admin/Customers/ReviewController.php index 1a49204..a5a0931 100644 --- a/src/Http/Controllers/Api/V1/Admin/Customers/ReviewController.php +++ b/src/Http/Controllers/Api/V1/Admin/Customers/ReviewController.php @@ -37,12 +37,14 @@ public function resource(): string public function update(int $id) { $this->validate(request(), [ - 'status' => 'required|in:approved,disapproved,pending', + 'status' => 'in:approved,disapproved,pending', + "rating" => "numeric|min:1|max:5", + "sort" => "numeric|min:1|max:100", ]); Event::dispatch('customer.review.update.before', $id); - $review = $this->getRepositoryInstance()->update(request()->only(['status']), $id); + $review = $this->getRepositoryInstance()->update(request()->only(['status','sort','rating']), $id); Event::dispatch('customer.review.update.after', $review);