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