departmentRepository = $departmentRepository; $this->employeeRepository = $employeeRepository; } /** * Display a listing of the resource. */ public function index() { // toastr() // ->info('Welcome back') // ->success('Data has been saved successfully!') // ->warning('Are you sure you want to proceed ?'); $data['title'] = 'Department List'; $data['departmentLists'] = $this->departmentRepository->findAll(); return view('admin::departments.index', $data); } /** * Show the form for creating a new resource. */ public function create() { // toastr('Department has been created!', 'success'); $data['title'] = 'Create Department'; $data['editable'] = false; $data['employeeLists'] = $this->employeeRepository->pluck(); return view('admin::departments.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { // try { $this->departmentRepository->create($request->all()); // toastr()->success('Department has been created!'); // } catch (\Throwable $th) { // toastr()->error($th->getMessage()); // } // toastr('Department has been created!', 'success'); // return back(); return redirect()->route('department.index')->with('sucess', 'adw'); } /** * Show the specified resource. */ public function show($id) { return view('admin::departments.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = 'Edit Department'; $data['editable'] = true; $data['employeeLists'] = $this->employeeRepository->pluck(); $data['department'] = $this->departmentRepository->getDepartmentById($id); return view('admin::departments.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { try { $this->departmentRepository->update($id, $request->except(['_token', '_method'])); toastr()->success('Department has been updated!'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('department.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { // } }