validated(); $slug = SlugHelper::get($validated); $subject = new Subject(); $subject->name = $validated['name']; $subject->description = $validated['description']; $subject->slug = $slug; $subject->position = $validated['position']; $subject->save(); Log::channel('app') ->info( 'CREATE предмет {subject} - user {user}', ['user' => Auth::user()->name, 'faculty' => $subject->name, 'data' => $validated] ); return redirect()->route('subjects.index'); } public function show(Subject $subject): View { return view('admin.catalog.direction.subject.show', compact('subject')); } public function edit(Subject $subject): View { return view('admin.catalog.direction.subject.edit', compact('subject')); } public function update(UpdateSubjectRequest $request, Subject $subject): RedirectResponse { $validated = $request->validated(); $oldData = $subject->toArray(); $subject->name = $validated['name']; $subject->description = $validated['description']; $subject->slug = $validated['slug']; $subject->position = $validated['position']; Log::channel('app') ->warning( 'UPDATE предмет {subject} - user {user}', [ 'user' => Auth::user()->name, 'subject' => $subject->name, 'oldData' => $oldData, 'newData' => $validated ] ); $subject->save(); return redirect()->route('subjects.index'); } public function destroy(Subject $subject): RedirectResponse { if ($subject->entranceExaminations()->exists()) { Log::channel('app') ->error( 'NOT DELETE предмет {subject} - user {user}', [ 'user' => Auth::user()->name, 'subject' => $subject->name, 'data' => $subject->toArray(), ] ); return back(); } Log::channel('app') ->critical( 'DELETE предмет {subject} - user {user}', [ 'user' => Auth::user()->name, 'subject' => $subject->name, 'data' => $subject->toArray(), ] ); $subject->delete(); return redirect()->route('subjects.index'); } }