contractRepository = $contractRepository; } /** * Display a listing of the resource. */ public function index() { $data['title'] = "Contract Lists"; $data['contractLists'] = $this->contractRepository->findAll(); return view('office::contracts.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = "Create Contract"; $data['editable'] = false; return view('office::contracts.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { try { $this->contractRepository->create($request->all()); toastr()->success('Contract Created Successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('contract.index'); } /** * Show the specified resource. */ public function show($id) { return view('office::contracts.show'); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = "Edit Contract"; $data['editable'] = true; $data['contract'] = $this->contractRepository->getContractById($id); return view('office::contracts.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { try { $this->contractRepository->update($id, $request->except(['_token', '_method'])); toastr()->success('Contract Updated Successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('contract.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { try { $this->contractRepository->delete($id); toastr()->success('Contract deleted successfully.'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('contract.index'); } }