form = B2buyForm::setAttributes()->toArray(); $this->modules = $this->modules(config('b2buy.contact.modules'), 'contact', guard_url('contact')); $this->repository = $b2buy; } /** * Display a list of b2buy. * * @return Response */ public function index(B2buyRequest $request) { $pageLimit = $request->input('pageLimit', config('database.pagination.limit')); $data = $this->repository ->pushFilter(RequestFilter::class) ->pushFilter(B2buyResourceFilter::class) ->setPresenter(B2buyListPresenter::class) ->simplePaginate($pageLimit) // ->withQueryString() ->toArray(); extract($data); $form = $this->form; $modules = $this->modules; return $this->response->setMetaTitle(trans('contact::b2buy.names')) ->view('contact::b2buy.index') ->data(compact('data', 'meta', 'links', 'modules', 'form')) ->output(); } /** * Display b2buy. * * @param Request $request * @param Model $b2buy * * @return Response */ public function show(B2buyRequest $request, B2buyRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response ->setMetaTitle(trans('app.view') . ' ' . trans('contact::b2buy.name')) ->data(compact('data', 'form', 'modules', 'form')) ->view('contact::b2buy.show') ->output(); } /** * Show the form for creating a new b2buy. * * @param Request $request *x * @return Response */ public function create(B2buyRequest $request, B2buyRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('contact::b2buy.name')) ->view('contact::b2buy.create') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Create new b2buy. * * @param Request $request * * @return Response */ public function store(B2buyRequest $request, B2buyRepositoryInterface $repository) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $repository->create($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.created', ['Module' => trans('contact::b2buy.name')])) ->code(204) ->data(compact('data')) ->status('success') ->url(guard_url('contact/b2buy/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/contact/b2buy')) ->redirect(); } } /** * Show b2buy for editing. * * @param Request $request * @param Model $b2buy * * @return Response */ public function edit(B2buyRequest $request, B2buyRepositoryInterface $repository) { $form = $this->form; $modules = $this->modules; $data = $repository->toArray(); return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('contact::b2buy.name')) ->view('contact::b2buy.edit') ->data(compact('data', 'form', 'modules')) ->output(); } /** * Update the b2buy. * * @param Request $request * @param Model $b2buy * * @return Response */ public function update(B2buyRequest $request, B2buyRepositoryInterface $repository) { try { $attributes = $request->all(); $repository->update($attributes); $data = $repository->toArray(); return $this->response->message(trans('messages.success.updated', ['Module' => trans('contact::b2buy.name')])) ->code(204) ->status('success') ->data(compact('data')) ->url(guard_url('contact/b2buy/' . $data['id'])) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('contact/b2buy/' . $repository->getRouteKey())) ->redirect(); } } /** * Remove the b2buy. * * @param Model $b2buy * * @return Response */ public function destroy(B2buyRequest $request, B2buyRepositoryInterface $repository) { try { $repository->delete(); $data = $repository->toArray(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('contact::b2buy.name')])) ->code(202) ->status('success') ->data(compact('data')) ->url(guard_url('contact/b2buy/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('contact/b2buy/' . $repository->getRouteKey())) ->redirect(); } } }