purchaseServiceRepository = $purchaseServiceRepository; } /** * Display a listing of the resource. */ public function index() { $data['title'] = "PurchaseService Lists"; $data['purchaseServiceLists'] = $this->purchaseServiceRepository->findAll(); return view('office::purchaseservices.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = "Create PurchaseService"; $data['editable'] = false; return view('office::purchaseservices.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { try { $this->purchaseServiceRepository->create($request->all()); toastr()->success('PurchaseService Created Successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('purchaseService.index'); } /** * Show the specified resource. */ public function show($id) { return view('office::purchaseservices.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = "Edit PurchaseService"; $data['editable'] = true; $data['purchaseService'] = $this->purchaseServiceRepository->getPurchaseServiceById($id); return view('office::purchaseservices.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { try { $this->purchaseServiceRepository->update($id, $request->except(['_token', '_method'])); toastr()->success('PurchaseService Updated Successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } // return redirect()->route('purchaseService.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { try { $this->purchaseServiceRepository->delete($id); toastr()->success('PurchaseService deleted successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('purchaseService.index'); } }