@@ -22,6 +22,7 @@ public function index(Request $request): JsonResponse
2222 'name ' => $ cat ->name ,
2323 'icon ' => $ cat ->icon ?? '📌 ' ,
2424 'type ' => $ cat ->type ,
25+ 'keywords ' => $ cat ->keywords ?? [],
2526 ]);
2627
2728 return $ this ->successResponse ($ categories , 'Daftar kategori berhasil diambil ' );
@@ -33,6 +34,8 @@ public function store(Request $request): JsonResponse
3334 'name ' => 'required|string|max:50|unique:categories,name ' ,
3435 'icon ' => 'required|string|max:4 ' ,
3536 'type ' => 'required|in:income,expense,both ' ,
37+ 'keywords ' => 'nullable|array ' ,
38+ 'keywords.* ' => 'string|max:50 ' ,
3639 ]);
3740
3841 $ category = Category::create ($ validated );
@@ -42,6 +45,7 @@ public function store(Request $request): JsonResponse
4245 'name ' => $ category ->name ,
4346 'icon ' => $ category ->icon ,
4447 'type ' => $ category ->type ,
48+ 'keywords ' => $ category ->keywords ?? [],
4549 ], 'Kategori berhasil ditambahkan ' , 201 );
4650 }
4751
@@ -56,6 +60,8 @@ public function update(Request $request, int $id): JsonResponse
5660 'name ' => 'sometimes|required|string|max:50|unique:categories,name, ' . $ id ,
5761 'icon ' => 'sometimes|required|string|max:4 ' ,
5862 'type ' => 'sometimes|required|in:income,expense,both ' ,
63+ 'keywords ' => 'nullable|array ' ,
64+ 'keywords.* ' => 'string|max:50 ' ,
5965 ]);
6066
6167 $ category ->update ($ validated );
@@ -65,6 +71,7 @@ public function update(Request $request, int $id): JsonResponse
6571 'name ' => $ category ->name ,
6672 'icon ' => $ category ->icon ,
6773 'type ' => $ category ->type ,
74+ 'keywords ' => $ category ->keywords ?? [],
6875 ], 'Kategori berhasil diperbarui ' );
6976 }
7077
0 commit comments