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