feat: Implement comprehensive product management, including categories, pricing, and integration into the order system.

This commit is contained in:
pbao9
2026-02-12 14:29:29 +07:00
parent 3b1beef66e
commit f3a679d7f3
25 changed files with 577 additions and 692 deletions
@@ -22,7 +22,28 @@ class OrderController extends Controller
try {
$customer = $request->user();
$result = $this->orderService->create($request->validated(), $customer);
$data = $request->validated();
// Convert UUID to ID for internal processing
$product = \App\Models\Product::where('uuid', $data['product_id'])->first();
if (!$product) {
// Should not happen if validation passes, but safety first (e.g. race condition or soft delete mismatch)
throw new \Exception('Sản phẩm không tìm thấy hoặc đã bị xóa.');
}
$data['product_id'] = $product->id;
$customer = $request->user();
if (!$customer) {
return response()->json([
'success' => false,
'message' => 'Người dùng chưa đăng nhập hoặc phiên đăng nhập hết hạn.'
], 401);
}
$result = $this->orderService->create($data, $customer);
return response()->json([
'success' => true,
@@ -65,4 +86,28 @@ class OrderController extends Controller
], 400);
}
}
public function getList(Request $request): JsonResponse
{
try {
$customer = $request->user();
$filters = [
'total_price' => $request->query('total_price'),
'pending' => $request->query('pending')
];
$orders = $this->orderRepo->getOrders($customer->id, $filters);
return response()->json([
'success' => true,
'data' => $orders
]);
} catch (\Exception $e) {
return response()->json([
'success' => false,
'message' => $e->getMessage()
], 400);
}
}
}