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