$service->getSubjects(), ]); } /** * Show the form for creating a new resource. */ public function create(): View { if(request()->user()->cannot('create', Subject::class)) { abort(403); } return view('subjects.create'); } /** * Store a newly created resource in storage. */ public function store(SubjectPostRequest $request): RedirectResponse { if(request()->user()->cannot('create', Subject::class)) { abort(403); } return redirect()->route( 'subjects.show', Subject::create($request->validated()), ); } /** * Display the specified resource. */ public function show(Subject $subject): View { return view('subjects.show', [ 'subject' => $subject, ]); } /** * Show the form for editing the specified resource. */ public function edit(Subject $subject): View { if(request()->user()->cannot('update', $subject)) { abort(403); } return view('subjects.edit', [ 'subject' => $subject, ]); } /** * Update the specified resource in storage. */ public function update(SubjectPostRequest $request, Subject $subject): RedirectResponse { if(request()->user()->cannot('update', $subject)) { abort(403); } return redirect()->route( 'subjects.show', $subject->update($request->validated()) ); } /** * Remove the specified resource from storage. */ public function destroy(Subject $subject): RedirectResponse { if(request()->user()->cannot('delete', $subject)) { abort(403); } $subject->delete(); return redirect()->route('subjects.index'); } public function exportToPDF(FileService $fileService) { return $fileService->exportSubjects(); } }