title = $request->materialTitle; $material->course_id = $request->courseId; $material->type = $request->materialType; $material->content_url = $request->contentURL; if ($material->save()) { $this->notice::success('Data Saved'); return redirect()->route('material.index'); } else { $this->notice::error('Please try again'); return redirect()->back()->withInput(); } } catch (Exception $e) { dd($e); $this->notice::error('Please try again'); return redirect()->back()->withInput(); } } /** * Display the specified resource. */ public function show(Material $material) { // } /** * Show the form for editing the specified resource. */ public function edit($id) { $course = Course::get(); $material = Material::findOrFail(encryptor('decrypt', $id)); return view('backend.course.material.edit', compact('course', 'material')); } /** * Update the specified resource in storage. */ public function update(Request $request, $id) { try { $material = Material::findOrFail(encryptor('decrypt', $id)); $material->title = $request->materialTitle; $material->course_id = $request->courseId; $material->type = $request->materialType; $material->content_url = $request->contentURL; if ($material->save()) { $this->notice::success('Data Saved'); return redirect()->route('material.index'); } else { $this->notice::error('Please try again'); return redirect()->back()->withInput(); } } catch (Exception $e) { dd($e); $this->notice::error('Please try again'); return redirect()->back()->withInput(); } } /** * Remove the specified resource from storage. */ public function destroy($id) { $data = Material::findOrFail(encryptor('decrypt', $id)); if ($data->delete()) { $this->notice::error('Data Deleted!'); return redirect()->back(); } } }