From 015dd40fc5b98ee83bf536245124599f0b31f94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=9D=99?= Date: Tue, 30 Nov 2021 09:58:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=83=AD=E9=94=80=E5=95=86=E5=93=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Http/Controllers/HotProductController.php | 26 +++++++++++++++++++ app/Endpoint/Api/routes.php | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 app/Endpoint/Api/Http/Controllers/HotProductController.php diff --git a/app/Endpoint/Api/Http/Controllers/HotProductController.php b/app/Endpoint/Api/Http/Controllers/HotProductController.php new file mode 100644 index 00000000..671687e5 --- /dev/null +++ b/app/Endpoint/Api/Http/Controllers/HotProductController.php @@ -0,0 +1,26 @@ +whereRelation('category', 'is_show', true) + ->latest('sales') + ->limit(20) + ->get(); + + return ProductSkuSimpleResource::collection($productSkus); + } +} diff --git a/app/Endpoint/Api/routes.php b/app/Endpoint/Api/routes.php index 2048b83d..f6640748 100644 --- a/app/Endpoint/Api/routes.php +++ b/app/Endpoint/Api/routes.php @@ -2,6 +2,7 @@ use App\Endpoint\Api\Http\Controllers\AdController; use App\Endpoint\Api\Http\Controllers\CaptchaController; +use App\Endpoint\Api\Http\Controllers\HotProductController; use App\Endpoint\Api\Http\Controllers\LoginController; use App\Endpoint\Api\Http\Controllers\LogoutController; use App\Endpoint\Api\Http\Controllers\ProductCategoryController; @@ -29,4 +30,5 @@ Route::group([ Route::get('product-categories', [ProductCategoryController::class, 'index']); Route::get('products', [ProductController::class, 'index']); + Route::get('hot-products', [HotProductController::class, 'index']); });