ticketRepository = $ticketRepository; } /** * Display a listing of the resource. */ public function index(Request $request) { $data['title'] = 'Ticket List'; $data['tickets'] = $this->ticketRepository->findAll(); $data['statusList'] = Ticket::STATUS; return view('pms::ticket.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['title'] = 'Create Ticket'; $data['statusList'] = Ticket::STATUS; return view('pms::ticket.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request): RedirectResponse { $inputData = $request->all(); $this->ticketRepository->create($inputData); toastr()->success('Ticket Created Succesfully'); return redirect()->route('ticket.index'); } /** * Show the specified resource. */ public function show($id) { $data['title'] = 'View Ticket'; $data['tickets'] = $this->ticketRepository->getTicketById($id); return view('pms::ticket.show', $data); } /** * Show the form for editing the specified resource. */ public function edit($id) { $data['title'] = 'Edit Ticket'; $data['ticket'] = $this->ticketRepository->getTicketById($id); return view('pms::ticket.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, $id): RedirectResponse { $inputData = $request->except(['_method', '_token']); try { $this->ticketRepository->update($id, $inputData); toastr()->success('Ticket Update Succesfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return redirect()->route('ticket.index'); } /** * Remove the specified resource from storage. */ public function destroy($id) { try { $this->ticketRepository->delete($id); toastr()->success('Ticket Deleted Succesfully'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } } }