validated(); $department = new Department(); $department->name = $validated['name']; $department->description = $validated['description']; $department->position = $validated['position']; $department->faculty_id = $validated['faculty_id']; $department->save(); return redirect()->route('departments.index'); } public function show(Department $department): View|Application|Factory|\Illuminate\Contracts\Foundation\Application { return view('catalog.department.show', compact('department')); } public function edit(Department $department): View|Application|Factory|\Illuminate\Contracts\Foundation\Application { $faculties = Faculty::pluck('name', 'id'); return view('catalog.department.edit', compact('department', 'faculties')); } /** * Update the specified resource in storage. */ public function update(UpdateDepartmentRequest $request, Department $department) { $validated = $request->validated(); $department->name = $validated['name']; $department->description = $validated['description']; $department->position = $validated['position']; $department->faculty_id = $validated['faculty_id']; $department->save(); return redirect()->route('departments.index'); } public function destroy(Department $department): RedirectResponse { $department->delete(); return redirect()->route('departments.index'); } }