serviceService = $serviceService; $this->serviceRepository = $serviceRepository; } /** * @OA\Get( * path="/services/get-list", * operationId="getServiceList", * tags={"Services"}, * summary="Get list of services", * description="Returns a paginated list of active services/products", * @OA\Parameter( * name="limit", * in="query", * description="Number of items per page", * required=false, * @OA\Schema(type="integer", default=10) * ), * @OA\Response( * response=200, * description="Successful operation", * @OA\JsonContent( * @OA\Property(property="error", type="boolean", example=false), * @OA\Property(property="message", type="string", example="Lấy dữ liệu thành công"), * @OA\Property(property="page_type", type="string", example="service"), * @OA\Property(property="data", type="array", @OA\Items( * @OA\Property(property="uuid", type="string", example="550e8400-e29b-41d4-a716-446655440000"), * @OA\Property(property="name", type="string", example="Cloud VPS Basic"), * @OA\Property(property="slug", type="string", example="cloud-vps-basic"), * @OA\Property(property="short_description", type="string", example="Basic VPS plan"), * @OA\Property(property="description", type="string"), * @OA\Property(property="thumbnail", type="string", example="https://example.com/images/vps.jpg"), * @OA\Property(property="product_type", type="string", example="vps"), * @OA\Property(property="specs", type="object", * @OA\Property(property="cpu", type="integer", example=2), * @OA\Property(property="ram", type="integer", example=4), * @OA\Property(property="disk", type="integer", example=50), * @OA\Property(property="bandwidth", type="integer", example=1000), * @OA\Property(property="gpu", type="string", nullable=true) * ), * @OA\Property(property="stock", type="integer", example=100), * @OA\Property(property="price", type="number", example=299000), * @OA\Property(property="price_sale", type="number", example=199000), * @OA\Property(property="pricing", type="object"), * @OA\Property(property="pricing_sale", type="object"), * @OA\Property(property="group", type="string", example="VPS"), * @OA\Property(property="os", type="array", @OA\Items( * @OA\Property(property="group", type="string", example="Ubuntu") * )) * )) * ) * ) * ) */ public function getService(Request $request) { $limit = $request->get('limit', 10); $services = $this->serviceService->getActiveServices($limit); return ServiceListResource::collection($services)->additional([ 'error' => false, 'message' => 'Lấy dữ liệu thành công', 'page_type' => 'service', ]); } /** * @OA\Get( * path="/services/{slug}", * operationId="getServiceDetail", * tags={"Services"}, * summary="Get service details", * description="Returns detailed information about a specific service/product", * @OA\Parameter( * name="slug", * in="path", * description="Service slug", * required=true, * @OA\Schema(type="string") * ), * @OA\Response( * response=200, * description="Successful operation", * @OA\JsonContent( * @OA\Property(property="error", type="boolean", example=false), * @OA\Property(property="message", type="string", example="Lấy dữ liệu thành công"), * @OA\Property(property="page_type", type="string", example="service"), * @OA\Property(property="data", type="object", * @OA\Property(property="uuid", type="string", example="550e8400-e29b-41d4-a716-446655440000"), * @OA\Property(property="name", type="string", example="Cloud VPS Basic"), * @OA\Property(property="slug", type="string", example="cloud-vps-basic"), * @OA\Property(property="short_description", type="string", example="Basic VPS plan"), * @OA\Property(property="description", type="string"), * @OA\Property(property="thumbnail", type="string", example="https://example.com/images/vps.jpg"), * @OA\Property(property="product_type", type="string", example="vps"), * @OA\Property(property="specs", type="object", * @OA\Property(property="cpu", type="integer", example=2), * @OA\Property(property="ram", type="integer", example=4), * @OA\Property(property="disk", type="integer", example=50), * @OA\Property(property="bandwidth", type="integer", example=1000), * @OA\Property(property="gpu", type="string", nullable=true) * ), * @OA\Property(property="stock", type="integer", example=100), * @OA\Property(property="price", type="number", example=299000), * @OA\Property(property="price_sale", type="number", example=199000), * @OA\Property(property="group", type="string", example="VPS"), * @OA\Property(property="os", type="array", @OA\Items( * @OA\Property(property="name", type="string", example="Ubuntu"), * @OA\Property(property="thumbnail", type="string"), * @OA\Property(property="versions", type="array", @OA\Items( * @OA\Property(property="version", type="string", example="22.04"), * @OA\Property(property="name", type="string", example="Ubuntu 22.04 LTS") * )) * )) * ) * ) * ), * @OA\Response( * response=404, * description="Service not found" * ) * ) */ public function getDetailService(Product $product) { $product->load([ 'osVersions.osGroup', 'category', 'pricings' => fn($q) => $q->where('is_active', 1), 'addons' ]); return response()->json([ 'error' => false, 'message' => 'Lấy dữ liệu thành công', 'page_type' => 'service', 'data' => new ServiceResource($product), ]); } }