feat: Implement client payment history endpoint and add type filtering to product category API.

This commit is contained in:
pbao9
2026-03-13 10:38:56 +07:00
parent a388eabe17
commit 5160ac967a
4 changed files with 199 additions and 115 deletions
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\Api\Service;
use App\Enums\Product\ProductTypeEnums;
use App\Http\Controllers\Controller;
use App\Http\Resources\Api\Service\ProductCategoryResource;
use App\Http\Resources\Api\Service\ServiceResource;
@@ -23,7 +24,14 @@ class ProductCategoryController extends Controller
* operationId="getProductCategoryList",
* tags={"Product Categories"},
* summary="Get list of product categories",
* description="Returns a list of active product categories with their children",
* description="Returns a list of active product categories filtered by type. The `type` parameter is required.",
* @OA\Parameter(
* name="type",
* in="query",
* description="Product type filter (e.g. vps, hosting, cloud, email, ssl, domain, web design, addon)",
* required=true,
* @OA\Schema(type="string")
* ),
* @OA\Response(
* response=200,
* description="Successful operation",
@@ -47,12 +55,35 @@ class ProductCategoryController extends Controller
* ))
* ))
* )
* ),
* @OA\Response(
* response=422,
* description="Missing or invalid type filter"
* )
* )
*/
public function getCategories(Request $request)
{
$type = $request->query('type');
if (!$type) {
return response()->json([
'error' => true,
'message' => 'Vui lòng chọn Phân loại sản phẩm',
'data' => [],
], 422);
}
if (!ProductTypeEnums::tryFrom($type)) {
return response()->json([
'error' => true,
'message' => 'Phân loại sản phẩm không hợp lệ',
'data' => [],
], 422);
}
$categories = ProductCategories::where('is_active', true)
->where('type', $type)
->whereNull('parent_id')
->with(['children' => function($query) {
$query->where('is_active', true)