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