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