promotionDemotionRepository = $promotionDemotionRepository; $this->designationRepository = $designationRepository; $this->departmentRepository = $departmentRepository; $this->employeeRepository = $employeeRepository; $this->fieldRepository = $fieldRepository; } /** * Display a listing of the resource. */ public function index() { $data['title'] = "Promotion/ Demotion Lists"; $data['promotionDemotionLists'] = $this->promotionDemotionRepository->findAll(); return view('admin::promotiondemotions.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['editable'] = false; $data['title'] = "Create Promotion/ Demotion"; $data['employeeList'] = $this->employeeRepository->pluck(); $data['designationList'] = $this->designationRepository->pluck(); $data['departmentList'] = $this->departmentRepository->pluck(); $data['rankingTypeList'] = $this->fieldRepository->getDropdownByAlias('ranking-type'); return view('admin::promotiondemotions.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { try { $this->promotionDemotionRepository->create($request->all()); toastr()->success('Record has been created!'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('promotionDemotion.index'); } /** * Show the specified resource. */ public function show($id) { return view('admin::promotiondemotions.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['editable'] = false; $data['title'] = "Edit Promotion/ Demotion"; $data['promotionDemotion'] = $this->promotionDemotionRepository->getPromotionDemotionById($id); $data['designationList'] = $this->designationRepository->pluck(); $data['employeeList'] = $this->employeeRepository->pluck(); $data['departmentList'] = $this->departmentRepository->pluck(); $data['rankingTypeList'] = $this->fieldRepository->getDropdownByAlias('ranking-type'); return view('admin::promotiondemotions.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { try { $this->promotionDemotionRepository->update($id, $request->all()); toastr()->success('Record has been updated'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('promotionDemotion.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { try { $this->promotionDemotionRepository->delete($id); toastr()->success('Record has been deleted!'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('promotionDemotion.index'); } }