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