validated(); $subject = new Subject(); $subject->name = $validated['name']; $subject->description = $validated['description']; $subject->slug = $validated['slug']; $subject->position = $validated['position']; $subject->save(); 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(); $subject->name = $validated['name']; $subject->description = $validated['description']; $subject->slug = $validated['slug']; $subject->position = $validated['position']; $subject->save(); return redirect()->route('subjects.index'); } public function destroy(Subject $subject): RedirectResponse { if ($subject->entranceExaminations()->exists()) { return back(); } $subject->delete(); return redirect()->route('subjects.index'); } }