validated(); $slug = SlugHelper::get($validated); $level = new EducationLevel(); $level->name = $validated['name']; $level->description = $validated['description']; $level->slug = $slug; $level->save(); Log::channel('app') ->info( 'CREATE уровень образования {educationLevel} - user {user}', ['user' => Auth::user()->name, 'educationLevel' => $level->name, 'data' => $validated] ); return redirect()->route('education_levels.index'); } public function show(EducationLevel $educationLevel): View { $directions = $educationLevel->directions(); return view( 'admin.catalog.direction.education_level.show', compact('educationLevel', 'directions') ); } public function edit(EducationLevel $educationLevel) { return view('admin.catalog.direction.education_level.edit', compact('educationLevel')); } public function update(UpdateEducationLevelRequest $request, EducationLevel $educationLevel): RedirectResponse { $validated = $request->validated(); $oldData = $educationLevel->toArray(); $educationLevel->name = $validated['name']; $educationLevel->description = $validated['description']; $educationLevel->slug = $validated['slug']; Log::channel('app') ->warning( 'UPDATE уровень образования {educationLevel} - user {user}', [ 'user' => Auth::user()->name, 'educationLevel' => $educationLevel->name, 'oldData' => $oldData, 'newData' => $validated ] ); $educationLevel->save(); return redirect()->route('education_levels.index'); } public function destroy(EducationLevel $educationLevel) { if ($educationLevel->directions()->exists()) { Log::channel('app') ->error( 'NOT DELETE уровень образования {educationLevel} - user {user}', [ 'user' => Auth::user()->name, 'educationLevel' => $educationLevel->name, 'data' => $educationLevel->toArray(), ] ); return back(); } Log::channel('app') ->critical( 'DELETE уровень образования {educationLevel} - user {user}', [ 'user' => Auth::user()->name, 'educationLevel' => $educationLevel->name, 'data' => $educationLevel->toArray(), ] ); $educationLevel->delete(); return redirect()->route('education_levels.index'); } }