validated(); $cost = new Cost(); $cost->position = $validated['position']; $cost->description = $validated['description']; $cost->cost = $validated['cost']; $cost->education_form_id = $validated['education_form_id']; $cost->direction_id = $validated['direction_id']; $cost->save(); return redirect()->route('costs.index'); } public function show(Cost $cost): View { return view('admin.catalog.direction.cost.show', compact('cost')); } public function edit(Cost $cost): View { $directions = Direction::pluck('name', 'id'); $educationForms = EducationForm::pluck('name', 'id'); return view( 'admin.catalog.direction.cost.edit', compact( 'cost', 'directions', 'educationForms', ) ); } public function update(UpdateCostRequest $request, Cost $cost): RedirectResponse { $validated = $request->validated(); $cost->position = $validated['position']; $cost->description = $validated['description']; $cost->cost = $validated['cost']; $cost->education_form_id = $validated['education_form_id']; $cost->direction_id = $validated['direction_id']; $cost->save(); return redirect()->route('costs.index'); } public function destroy(Cost $cost): RedirectResponse { $cost->delete(); return redirect()->route('costs.index'); } }