repository = $region_area; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\B2buy\Shipping\Repositories\Criteria\RegionAreaResourceCriteria::class); } /** * Display a list of region_area. * * @return Response */ public function index(RegionAreaRequest $request) { return $this->repository ->setPresenter(\B2buy\Shipping\Repositories\Presenter\RegionAreaPresenter::class) ->paginate(); } /** * Display region_area. * * @param Request $request * @param Model $region_area * * @return Response */ public function show(RegionAreaRequest $request, RegionArea $region_area) { return $region_area->setPresenter(\B2buy\Shipping\Repositories\Presenter\RegionAreaListPresenter::class); ; } /** * Create new region_area. * * @param Request $request * * @return Response */ public function store(RegionAreaRequest $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_area.name')]); $code = 204; $status = 'success'; $url = guard_url('shipping/region_area/' . $region_area->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('shipping/region_area'); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Update the region_area. * * @param Request $request * @param Model $region_area * * @return Response */ public function update(RegionAreaRequest $request, RegionArea $region_area) { try { $data = $request->all(); $region_area->update($data); $message = trans('messages.success.updated', ['Module' => trans('shipping::region_area.name')]); $code = 204; $status = 'success'; $url = guard_url('shipping/region_area/' . $region_area->getRouteKey()); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('shipping/region_area/' . $region_area->getRouteKey()); } return compact('data', 'message', 'code', 'status', 'url'); } /** * Remove the region_area. * * @param Model $region_area * * @return Response */ public function destroy(RegionAreaRequest $request, RegionArea $region_area) { try { $region_area->delete(); $message = trans('messages.success.deleted', ['Module' => trans('shipping::region_area.name')]); $code = 202; $status = 'success'; $url = guard_url('shipping/region_area/0'); } catch (Exception $e) { $message = $e->getMessage(); $code = 400; $status = 'error'; $url = guard_url('shipping/region_area/' . $region_area->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); } }