File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,26 @@ public function __construct(
1919 protected ItemService $ itemService
2020 ) {}
2121
22+ /**
23+ * Look up item info by item_code (read-only, no stock change).
24+ */
25+ public function lookup (string $ code ): JsonResponse
26+ {
27+ $ item = $ this ->itemService ->findByCode ($ code );
28+
29+ if (! $ item ) {
30+ return response ()->json ([
31+ 'status ' => 'error ' ,
32+ 'message ' => 'Item not found ' ,
33+ ], 404 );
34+ }
35+
36+ return response ()->json ([
37+ 'status ' => 'success ' ,
38+ 'data ' => $ item ,
39+ ], 200 );
40+ }
41+
2242 /**
2343 * Handle RFID scan and adjust item quantity.
2444 */
Original file line number Diff line number Diff line change @@ -221,6 +221,17 @@ protected function deleteImages(Item $item)
221221 }
222222 }
223223
224+ /**
225+ * Find an item by its item_code
226+ *
227+ * @param string $itemCode
228+ * @return Item|null
229+ */
230+ public function findByCode (string $ itemCode ): ?Item
231+ {
232+ return $ this ->itemRepo ->findByCode ($ itemCode );
233+ }
234+
224235 /**
225236 * Adjust item quantity via RFID scan.
226237 * Use action 'add' to increase and 'deduct' to decrease.
@@ -232,7 +243,7 @@ protected function deleteImages(Item $item)
232243 */
233244 public function adjustQuantityByCode (string $ itemCode , string $ action , int $ quantity ): array
234245 {
235- $ item = $ this ->itemRepo -> findByCode ($ itemCode );
246+ $ item = $ this ->findByCode ($ itemCode );
236247
237248 if (! $ item ) {
238249 return ['success ' => false , 'message ' => 'Item not found ' ];
Original file line number Diff line number Diff line change 88 ->name ('rfid. ' )
99 ->group (function () {
1010
11- // Scan item by item_code
11+ // Look up item info by item_code (read-only, no stock change)
12+ Route::get ('/item/{code} ' , [RfidController::class, 'lookup ' ])
13+ ->name ('lookup ' );
14+
15+ // Scan item by item_code (adjusts stock)
1216 Route::post ('/scan ' , [RfidController::class, 'scan ' ])
1317 ->name ('scan ' );
1418 });
You can’t perform that action at this time.
0 commit comments