paymentReppository->filter( $request->merge(['page' => $request->get('page') ?? 1])->all() ); $title = 'List Payment'; return view('administrator.pages.payment.index', compact('payments', 'title')); } public function create() { $title = 'Add new Payment Method'; return view('administrator.pages.payment.add', compact('title')); } public function store(PaymentRequest $request) { $request->validated(); DB::beginTransaction(); try { $this->paymentReppository->create($request->all()); DB::commit(); } catch (\Exception $exception) { DB::rollBack(); return back()->withErrors($exception->getMessage()); } return redirect()->route('payment.index')->with('success', 'Added successfully'); } public function edit(int $id = 0) { $payment = $this->paymentReppository->find($id); if (! $payment) { return back()->withErrors('Invalid request'); } $title = 'Edit Payment Method'; return view('administrator.pages.payment.edit', compact('title', 'payment')); } public function update(int $id = 0, PaymentRequest $request) { $payment = $this->paymentReppository->find($id); if (! $payment) { return back()->withErrors('Invalid request'); } $request->validated(); DB::beginTransaction(); try { $this->paymentReppository->update($id, $request->all()); DB::commit(); } catch (\Exception $exception) { DB::rollBack(); return back()->withErrors($exception->getMessage()); } return redirect()->route('payment.index')->with('success', 'Updated successfully'); } public function destroy(int $id = 0) { $payment = $this->paymentReppository->find($id); if (! $payment) { return back()->withErrors('Invalid request'); } DB::beginTransaction(); try { $this->paymentReppository->delete($id); DB::commit(); } catch (\Exception $exception) { DB::rollBack(); return back()->withErrors($exception->getMessage()); } return redirect()->route('payment.index')->with('success', 'Deleted successfully'); } }