repository = $ticket_system; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Litecms\TicketSystem\Repositories\Criteria\TicketSystemResourceCriteria::class); } /** * Display a list of ticket_system. * * @return Response */ public function index(TicketSystemRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Litecms\TicketSystem\Repositories\Presenter\TicketSystemPresenter::class) ->$function(); } $ticket_systems = $this->repository->paginate(); return $this->response->title(trans('ticket_system::ticket_system.names')) ->view('ticket_system::ticket_system.index', true) ->data(compact('ticket_systems')) ->output(); } /** * Display ticket_system. * * @param Request $request * @param Model $ticket_system * * @return Response */ public function show(TicketSystemRequest $request, TicketSystem $ticket_system) { if ($ticket_system->exists) { $view = 'ticket_system::ticket_system.show'; } else { $view = 'ticket_system::ticket_system.new'; } return $this->response->title(trans('app.view') . ' ' . trans('ticket_system::ticket_system.name')) ->data(compact('ticket_system')) ->view($view, true) ->output(); } /** * Show the form for creating a new ticket_system. * * @param Request $request * * @return Response */ public function create(TicketSystemRequest $request) { $ticket_system = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('ticket_system::ticket_system.name')) ->view('ticket_system::ticket_system.create', true) ->data(compact('ticket_system')) ->output(); } /** * Create new ticket_system. * * @param Request $request * * @return Response */ public function store(TicketSystemRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $ticket_system = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('ticket_system::ticket_system.name')])) ->code(204) ->status('success') ->url(guard_url('ticket_system/ticket_system/' . $ticket_system->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/ticket_system/ticket_system')) ->redirect(); } } /** * Show ticket_system for editing. * * @param Request $request * @param Model $ticket_system * * @return Response */ public function edit(TicketSystemRequest $request, TicketSystem $ticket_system) { return $this->response->title(trans('app.edit') . ' ' . trans('ticket_system::ticket_system.name')) ->view('ticket_system::ticket_system.edit', true) ->data(compact('ticket_system')) ->output(); } /** * Update the ticket_system. * * @param Request $request * @param Model $ticket_system * * @return Response */ public function update(TicketSystemRequest $request, TicketSystem $ticket_system) { try { $attributes = $request->all(); $ticket_system->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('ticket_system::ticket_system.name')])) ->code(204) ->status('success') ->url(guard_url('ticket_system/ticket_system/' . $ticket_system->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('ticket_system/ticket_system/' . $ticket_system->getRouteKey())) ->redirect(); } } /** * Remove the ticket_system. * * @param Model $ticket_system * * @return Response */ public function destroy(TicketSystemRequest $request, TicketSystem $ticket_system) { try { $ticket_system->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('ticket_system::ticket_system.name')])) ->code(202) ->status('success') ->url(guard_url('ticket_system/ticket_system/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('ticket_system/ticket_system/' . $ticket_system->getRouteKey())) ->redirect(); } } /** * Remove multiple ticket_system. * * @param Model $ticket_system * * @return Response */ public function delete(TicketSystemRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('ticket_system::ticket_system.name')])) ->status("success") ->code(202) ->url(guard_url('ticket_system/ticket_system')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/ticket_system/ticket_system')) ->redirect(); } } /** * Restore deleted ticket_systems. * * @param Model $ticket_system * * @return Response */ public function restore(TicketSystemRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('ticket_system::ticket_system.name')])) ->status("success") ->code(202) ->url(guard_url('/ticket_system/ticket_system')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/ticket_system/ticket_system/')) ->redirect(); } } }