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