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