view('admin/hotels/index', compact('hotels')); } /** * Показать форму создания отеля. */ public function create() { return view('admin.hotels.create'); } /** * Сохранить новый отель. */ public function store(Request $request) { $validated = $request->validate([ 'name' => 'required|string|max:255', 'address' => 'nullable|string', 'phone' => 'nullable|string', ]); Hotel::create($validated); return redirect()->route('admin.hotels.index')->with('success', 'Отель добавлен!'); } /** * Показать форму редактирования отеля. */ public function edit(Hotel $hotel) { return view('admin.hotels.edit', compact('hotel')); } /** * Обновить отель. */ public function update(Request $request, Hotel $hotel) { $validated = $request->validate([ 'name' => 'required|string|max:255', 'address' => 'nullable|string', 'phone' => 'nullable|string', ]); $hotel->update($validated); return redirect()->route('admin.hotels.index')->with('success', 'Отель обновлён!'); } /** * Удалить отель. */ public function destroy(Hotel $hotel) { $hotel->delete(); return redirect()->route('admin.hotels.index')->with('success', 'Отель удалён!'); } }