designationRepository = $designationRepository; $this->adminService = $adminService; } /** * Display a listing of the resource. */ public function index() { $data['title'] = 'Designation List'; $data['designationLists'] = $this->designationRepository->findAll(); return view('admin::designations.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = 'Create Designation'; $data['editable'] = false; $data['departmentList'] = $this->adminService->pluckDepartments(); return view('admin::designations.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { $data = $request->except(['_method', '_token']); $this->designationRepository->create($data); flash()->addSuccess('Department Data Created!'); return redirect()->route('designation.index'); } /** * Show the specified resource. */ public function show($id) { return view('admin::designations.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = 'Edit Designation'; $data['editable'] = true; $data['designation'] = $this->designationRepository->getDesignationById($id); $data['departmentList'] = $this->adminService->pluckDepartments(); return view('admin::designations.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { $data = $request->except(['_method', '_token']); $desgination = $this->designationRepository->getDesignationById($id); $desgination->update($data); flash()->addSuccess('Department Data Updated!'); return redirect()->route('designation.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { $this->designationRepository->delete($id); flash()->addSuccess('Designation Deleted Succesfully'); return response()->json(['status' => true, 'message' => 'Designation Delete Succesfully']); } }