Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,75 @@
], 500);
}
});





Route::get('/products', function () {
return response()->json([
[
'id' => 1,
'name' => 'CloudShopt Hoodie',
'price' => 49.90,
'currency' => 'EUR',
'sku' => 'CS-HOODIE-001',
'in_stock' => true,
],
[
'id' => 2,
'name' => 'CloudShopt T-Shirt',
'price' => 19.90,
'currency' => 'EUR',
'sku' => 'CS-TSHIRT-001',
'in_stock' => true,
],
[
'id' => 3,
'name' => 'CloudShopt Mug',
'price' => 12.90,
'currency' => 'EUR',
'sku' => 'CS-MUG-001',
'in_stock' => false,
],
]);
});


Route::get('/products/{id}', function (string $id) {
$products = [
1 => [
'id' => 1,
'name' => 'CloudShopt Hoodie',
'price' => 49.90,
'currency' => 'EUR',
'sku' => 'CS-HOODIE-001',
'in_stock' => true,
'description' => 'Warm hoodie for cloud-native builders.',
],
2 => [
'id' => 2,
'name' => 'CloudShopt T-Shirt',
'price' => 19.90,
'currency' => 'EUR',
'sku' => 'CS-TSHIRT-001',
'in_stock' => true,
'description' => 'Soft cotton tee with CloudShopt logo.',
],
3 => [
'id' => 3,
'name' => 'CloudShopt Mug',
'price' => 12.90,
'currency' => 'EUR',
'sku' => 'CS-MUG-001',
'in_stock' => false,
'description' => 'Ceramic mug for your morning deploys.',
],
];

if (!isset($products[(int)$id])) {
return response()->json(['message' => 'Product not found'], 404);
}

return response()->json($products[(int)$id]);
});