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']); });