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