validated(); $directionProfile = new DirectionProfile(); $directionProfile->name = $validated['name']; $directionProfile->description = $validated['description']; $directionProfile->slug = $validated['slug']; $directionProfile->position = $validated['position']; $directionProfile->save(); return redirect()->route('direction_profiles.index'); } public function show(DirectionProfile $directionProfile): View { return view('admin.catalog.direction.direction_profile.show', compact('directionProfile')); } public function edit(DirectionProfile $directionProfile): View { $directions = Direction::pluck('name', 'id'); return view( 'admin.catalog.direction.direction_profile.edit', compact('directionProfile', 'directions') ); } public function update(UpdateDirectionProfileRequest $request, DirectionProfile $directionProfile): RedirectResponse { $validated = $request->validated(); $directionProfile->name = $validated['name']; $directionProfile->description = $validated['description']; $directionProfile->slug = $validated['slug']; $directionProfile->position = $validated['position']; $directionProfile->save(); return redirect()->route('direction_profiles.index'); } public function destroy(DirectionProfile $directionProfile): RedirectResponse { if ($directionProfile->direction()->exists()) { return back(); } $directionProfile->delete(); return redirect()->route('direction_profiles.index'); } }