$grade, 'subjects' => Subject::all(), ]); } public function store(GradeSubjectPostRequest $request, Grade $grade): RedirectResponse { $grade->subjects()->syncWithoutDetaching($request->subject_id); return redirect()->route('grades.show', $grade); } public function destroy(Grade $grade, Subject $subject): RedirectResponse { $grade->subjects()->detach($subject); return redirect()->route('grades.show', $grade); } public function journal(Grade $grade, Subject $subject, JournalService $service): View { return view('grade-subject.journal', [ 'lessons' => $grade->lessons()->where('subject_id', $subject->id)->with('students')->get(), 'students' => $grade->students()->orderBy('last_name')->get(), 'grade' => $grade, 'subject' => $subject, ]); } public function exportToExcel(Grade $grade, Subject $subject, FileService $service) { return $service->exportJournal($grade, $subject); } }