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