transferRepository = $transferRepository; $this->employeeRepository = $employeeRepository; $this->adminService = $adminService; } /** * Display a listing of the resource. */ public function index() { $data['title'] = 'Transfer Lists'; $data['transferLists'] = $this->transferRepository->findAll(); return view('admin::transfers.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = 'Create Transfer'; $data['editable'] = false; $data['employeeLists'] = $this->employeeRepository->pluck(); $data['departmentLists'] = $this->adminService->pluckDepartments(); return view('admin::transfers.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { try { $this->transferRepository->create($request->all()); toastr()->success('Transfer Created Successfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('transfer.index'); } /** * Show the specified resource. */ public function show($id) { return view('admin::transfers.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { try { $data['title'] = 'Edit Transfer'; $data['editable'] = true; $data['employeeLists'] = $this->employeeRepository->pluck(); $data['departmentLists'] = $this->adminService->pluckDepartments(); $data['transfer'] = $this->transferRepository->getTransferById($id); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return view('admin::transfers.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { try { $this->transferRepository->update($id, $request->except(['_method','_token'])); toastr()->success('Transfer Updated Successfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('transfer.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { try { $this->transferRepository->delete($id); toastr()->success('Transfer Deleted Successfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('transfer.index'); } }