validate([ 'name' => 'required|string|max:255', 'address' => 'nullable|string', ]); $hotel = Hotel::create($validated); return response()->json($hotel, 201); } public function show($id) { $hotel = Hotel::findOrFail($id); return response()->json($hotel); } public function update(Request $request, $id) { $hotel = Hotel::findOrFail($id); $validated = $request->validate([ 'name' => 'required|string|max:255', 'address' => 'nullable|string', ]); $hotel->update($validated); return response()->json($hotel); } public function destroy($id) { $hotel = Hotel::findOrFail($id); //if ($hotel->bookings()->exists()) { // return response()->json(['error' => 'Cannot delete hotel with bookings'], 400); //} $hotel->delete(); return response()->json(['message' => 'Hotel deleted successfully']); } }