/* Decoded by unphp.net */ ?>b"get(); return view('admin.syllabus.create',compact('webinar')); } public function store(Request $request) { $request->validate([ 'webinar_id' => 'required', 'syllabus' => 'required', ]); $syllabus = new CourseSyllabus; $syllabus->webinar_id = $request->input('webinar_id'); if($request->hasfile('syllabus')) { $file = $request->file('syllabus'); $extenstion = $file->getClientOriginalExtension(); $filename = time().'.'.$extenstion; $file->move('admin/syllabus/', $filename); $syllabus->syllabus = $filename; } if($request->hasfile('handbook')) { $file = $request->file('handbook'); $extenstion = $file->getClientOriginalExtension(); $filename = time().'.'.$extenstion; $file->move('admin/handbook/', $filename); $syllabus->handbook = $filename; } $syllabus->save(); $data ['books']= CourseSyllabus::all(); return view('admin.syllabus.list',$data); } public function list(){ $data ['books']= CourseSyllabus::all(); return view('admin.syllabus.list',$data); } public function edit($bookId){ $data['book'] = CourseSyllabus::find($bookId); $webinar=Webinar::where('status','active')->get(); return view('admin.syllabus.edit',$data,compact('webinar')); } public function update(Request $request, $id){ $request->validate([ 'webinar_id' => 'required', 'syllabus' => 'required', ]); $book = CourseSyllabus::findOrFail($id); $book->webinar_id = $request->input('webinar_id'); if ($request->hasFile('syllabus')) { $oldFilePath = public_path('admin/syllabus/' . $book->syllabus); if (file_exists($oldFilePath) && is_file($oldFilePath)) { // Delete the old file unlink($oldFilePath); } // Upload the new file $file = $request->file('syllabus'); $extension = $file->getClientOriginalExtension(); $filename = time() . '.' . $extension; $file->move(public_path('admin/syllabus/'), $filename); // Update the syllabus field in the database $book->syllabus = $filename; } if ($request->hasFile('handbook')) { $oldFilePath = public_path('admin/handbook/' . $book->handbook); if (file_exists($oldFilePath) && is_file($oldFilePath)) { unlink($oldFilePath); } // Upload the new file $file = $request->file('handbook'); $extension = $file->getClientOriginalExtension(); $filename = time() . '.' . $extension; $file->move(public_path('admin/handbook/'), $filename); // Update the syllabus field in the database $book->handbook = $filename; } $book->update(); $data ['books']= CourseSyllabus::all(); return view('admin.syllabus.list',$data); } public function delete($id){ $book = CourseSyllabus::find($id); if (!$book) { return back()->with('error', 'Book not found.'); } $slabus = public_path('admin/syllabus/'.$book->syllabus); $handbook = public_path('admin/handbook/'.$book->handbook); if (File::exists($slabus)) { unlink($slabus); } if (File::exists($handbook)) { unlink($handbook); } $book->delete(); return back()->with('success', 'Book deleted successfully.'); } } "