validate([ 'rack_id' => 'required|exists:stock_rack,rack_id', 'shelf_symbol' => 'required|string|max:50', 'shelf_name' => 'required|string|max:100', ]); $shelf = StockShelf::create($data); return response()->json($shelf, 201); } public function update(Request $request, StockShelf $shelf) { $data = $request->validate([ 'shelf_symbol' => 'sometimes|required|string|max:50', 'shelf_name' => 'sometimes|required|string|max:100', ]); $shelf->update($data); return response()->json($shelf); } public function destroy(StockShelf $shelf) { $shelf->delete(); return response()->json(null, 204); } }