settingRepository = $settingRepository; } public function index() { $data['title'] = 'Categories List'; $data['categories'] = $this->settingRepository->findAll(); return view('setting::setting.edit', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = 'Create Setting'; $data['status'] = Setting::STATUS; return view('setting::setting.edit', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { $inputData = $request->all(); $this->settingRepository->create($inputData); toastr()->success('Setting Created Succesfully'); $data['setting'] = $this->settingRepository->getSettingById($request->id); return redirect()->route('setting.edit'); } /** * Show the specified resource. */ public function show($id) { $data['title'] = 'Show Setting'; $data['status'] = Setting::STATUS; $data['setting'] = $this->settingRepository->getSettingById($id); return view('setting::setting.edit', $data); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = 'Edit Setting'; $data['status'] = Setting::STATUS; $data['setting'] = $this->settingRepository->getSettingById($id); return view('setting::setting.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { $inputData = $request->except(['_method', '_token']); $this->settingRepository->update($id, $inputData); $data['setting'] = $this->settingRepository->getSettingById($id); return redirect()->route('setting.edit',$data); } /** * Remove the specified resource from storage. */ public function destroy($id) { try { $SettingModel = $this->settingRepository->getSettingById($id); $SettingModel->delete(); toastr()->success('Product Delete Succesfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return response()->json(['status' => true, 'message' => 'Setting Delete Succesfully']); } }