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