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