$this->service->paginated( ...$request->validatedWithDefaults(), gender: $request->validated('gender'), departmentId: $request->validated('department_id'), status: $request->validated('status'), ), 'departments' => $this->departmentService->getAllForSelect(), 'statuses' => StudentStatus::options(), 'filters' => $request->only(['gender', 'department_id', 'status']), ]); } public function create(): Response { return Inertia::render('admin/users/students/create', [ 'departments' => $this->departmentService->getAllForSelect(), 'lecturers' => $this->lecturerService->getAllForSelect(), ]); } public function store(StudentRequest $request): RedirectResponse { $this->service->create($request->validated()); Inertia::flash('toast', ['type' => 'success', 'message' => 'Mahasiswa berhasil ditambahkan.']); return to_route('admin.users.students.index'); } public function edit(User $user): Response { $user->load(['profile', 'student.department', 'student.academicAdvisor.user.profile']); return Inertia::render('admin/users/students/edit', [ 'user' => $user, 'departments' => $this->departmentService->getAllForSelect(), 'lecturers' => $this->lecturerService->getAllForSelect(), ]); } public function update(StudentRequest $request, User $user): RedirectResponse { $this->service->update($user, $request->validated()); Inertia::flash('toast', ['type' => 'success', 'message' => 'Mahasiswa berhasil diperbarui.']); return to_route('admin.users.students.index'); } public function destroy(User $user): RedirectResponse { $this->service->delete($user); return Inertia::flash('toast', ['type' => 'success', 'message' => 'Mahasiswa berhasil dihapus.'])->back(); } public function resetPassword(User $user): RedirectResponse { $this->service->resetPassword($user); return Inertia::flash('toast', ['type' => 'success', 'message' => 'Kata sandi berhasil direset.'])->back(); } public function updateStatus(StudentStatusRequest $request, User $user): RedirectResponse { $this->service->updateStatus($user, $request->validated('status')); return Inertia::flash('toast', ['type' => 'success', 'message' => 'Status mahasiswa berhasil diperbarui.'])->back(); } public function export(PaginatedRequest $request): BinaryFileResponse { return Excel::download(new StudentsExport( search: $request->validated('search') ?? '', gender: $request->validated('gender'), departmentId: $request->validated('department_id'), status: $request->validated('status'), ), 'mahasiswa.xlsx'); } }