repository = $region_surcharge; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\B2buy\Shipping\Repositories\Criteria\RegionSurchargeResourceCriteria::class); } /** * Display a list of region_surcharge. * * @return Response */ public function index(RegionSurchargeRequest $request) { return $this->repository ->setPresenter(\B2buy\Shipping\Repositories\Presenter\RegionSurchargePresenter::class) ->paginate(); } /** * Display region_surcharge. * * @param Request $request * @param Model $region_surcharge * * @return Response */ public function show(RegionSurchargeRequest $request, RegionSurcharge $region_surcharge) { return $region_surcharge->setPresenter(\B2buy\Shipping\Repositories\Presenter\RegionSurchargeListPresenter::class); ; } /** * Create new region_surcharge. * * @param Request $request * * @return Response */ public function store(RegionSurchargeRequest $request) { try { $data = $request->all(); $data['user_id'] = user_id(); $data['user_type'] = user_type(); $data = $this->repository->create($data); $message = trans('messages.success.created', ['Module' => trans('shipping::region_surcharge.name')]); $code = 204; $status = 'success'; $url = guard_url('shipping/region_surcharge/' . $region_surcharge->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('shipping/region_surcharge'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the region_surcharge. * * @param Request $request * @param Model $region_surcharge * * @return Response */ public function update(RegionSurchargeRequest $request, RegionSurcharge $region_surcharge) { try { $data = $request->all(); $region_surcharge->update($data); $message = trans('messages.success.updated', ['Module' => trans('shipping::region_surcharge.name')]); $code = 204; $status = 'success'; $url = guard_url('shipping/region_surcharge/' . $region_surcharge->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('shipping/region_surcharge/' . $region_surcharge->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the region_surcharge. * * @param Model $region_surcharge * * @return Response */ public function destroy(RegionSurchargeRequest $request, RegionSurcharge $region_surcharge) { try { $region_surcharge->delete(); $message = trans('messages.success.deleted', ['Module' => trans('shipping::region_surcharge.name')]); $code = 202; $status = 'success'; $url = guard_url('shipping/region_surcharge/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('shipping/region_surcharge/' . $region_surcharge->getRouteKey()); } return compact('message', 'code', 'status', 'url'); } /** * Return the form elements as json. * * @param String $element * * @return json */ public function form($element = 'fields') { $form = new Form(); return $form->form($element, true); } }