paymentRepository = $paymentRepository; $this->employeeRepository = $employeeRepository; } /** * Display a listing of the resource. */ public function index() { $data['title'] = "Payment Lists"; $data['paymentLists'] = $this->paymentRepository->findAll(); return view('payroll::payments.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = "Create Payment"; $data['editable'] = false; $data['employeeLists'] = $this->employeeRepository->pluck(); return view('payroll::payments.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { $this->paymentRepository->create($request->all()); toastr()->success('Payment Created Successfully.'); return redirect()->route('payment.index'); } /** * Show the specified resource. */ public function show($id) { return view('payroll::payments.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = "Edit Payment"; $data['editable'] = true; $data['payment'] = $this->paymentRepository->getPaymentById($id); return view('payroll::payments.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { try { $this->paymentRepository->update($id, $request->all()); toastr()->success('Payment Updated Successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('payment.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { // } }