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