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