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