Skip to content

Commit 1c0fce1

Browse files
author
ahmadhuss
committed
feat: Added Post API Route and updated controller called CategoryController.php
1 parent 9a5ff17 commit 1c0fce1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

app/Http/Controllers/Api/CategoryController.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,11 @@ public function show(Category $category){
3131
return new CategoryResource($category);
3232
}
3333

34+
// Post store
35+
public function store(Request $request) {
36+
$category = Category::create($request->all());
37+
return new CategoryResource($category);
38+
}
39+
3440

3541
}

routes/api.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
// "{category}" will use Route Model Binding
2929
Route::get('categories/{category}', [CategoryController::class, 'show']);
30+
// categories POST Request
31+
Route::post('categories', [CategoryController::class, 'store']);
3032

3133

3234
// Product API

0 commit comments

Comments
 (0)