repository = $bankoffer; $this->repository ->pushCriteria(\Litepie\Repository\Criteria\RequestCriteria::class) ->pushCriteria(\Superrobota\Bankoffer\Repositories\Criteria\BankofferResourceCriteria::class); } /** * Display a list of bankoffer. * * @return Response */ public function index(BankofferRequest $request) { $view = $this->response->theme->listView(); if ($this->response->typeIs('json')) { $function = camel_case('get-' . $view); return $this->repository ->setPresenter(\Superrobota\Bankoffer\Repositories\Presenter\BankofferPresenter::class) ->$function(); } $bankoffers = $this->repository->paginate(); return $this->response->title(trans('bankoffer::bankoffer.names')) ->view('bankoffer::bankoffer.index', true) ->data(compact('bankoffers')) ->output(); } /** * Display bankoffer. * * @param Request $request * @param Model $bankoffer * * @return Response */ public function show(BankofferRequest $request, Bankoffer $bankoffer) { if ($bankoffer->exists) { $view = 'bankoffer::bankoffer.show'; } else { $view = 'bankoffer::bankoffer.new'; } return $this->response->title(trans('app.view') . ' ' . trans('bankoffer::bankoffer.name')) ->data(compact('bankoffer')) ->view($view, true) ->output(); } /** * Show the form for creating a new bankoffer. * * @param Request $request * * @return Response */ public function create(BankofferRequest $request) { $bankoffer = $this->repository->newInstance([]); return $this->response->title(trans('app.new') . ' ' . trans('bankoffer::bankoffer.name')) ->view('bankoffer::bankoffer.create', true) ->data(compact('bankoffer')) ->output(); } /** * Create new bankoffer. * * @param Request $request * * @return Response */ public function store(BankofferRequest $request) { try { $attributes = $request->all(); $attributes['user_id'] = user_id(); $attributes['user_type'] = user_type(); $bankoffer = $this->repository->create($attributes); return $this->response->message(trans('messages.success.created', ['Module' => trans('bankoffer::bankoffer.name')])) ->code(204) ->status('success') ->url(guard_url('bankoffer/bankoffer/' . $bankoffer->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('/bankoffer/bankoffer')) ->redirect(); } } /** * Show bankoffer for editing. * * @param Request $request * @param Model $bankoffer * * @return Response */ public function edit(BankofferRequest $request, Bankoffer $bankoffer) { return $this->response->title(trans('app.edit') . ' ' . trans('bankoffer::bankoffer.name')) ->view('bankoffer::bankoffer.edit', true) ->data(compact('bankoffer')) ->output(); } /** * Update the bankoffer. * * @param Request $request * @param Model $bankoffer * * @return Response */ public function update(BankofferRequest $request, Bankoffer $bankoffer) { try { $attributes = $request->all(); $bankoffer->update($attributes); return $this->response->message(trans('messages.success.updated', ['Module' => trans('bankoffer::bankoffer.name')])) ->code(204) ->status('success') ->url(guard_url('bankoffer/bankoffer/' . $bankoffer->getRouteKey())) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('bankoffer/bankoffer/' . $bankoffer->getRouteKey())) ->redirect(); } } /** * Remove the bankoffer. * * @param Model $bankoffer * * @return Response */ public function destroy(BankofferRequest $request, Bankoffer $bankoffer) { try { $bankoffer->delete(); return $this->response->message(trans('messages.success.deleted', ['Module' => trans('bankoffer::bankoffer.name')])) ->code(202) ->status('success') ->url(guard_url('bankoffer/bankoffer/0')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->code(400) ->status('error') ->url(guard_url('bankoffer/bankoffer/' . $bankoffer->getRouteKey())) ->redirect(); } } /** * Remove multiple bankoffer. * * @param Model $bankoffer * * @return Response */ public function delete(BankofferRequest $request, $type) { try { $ids = hashids_decode($request->input('ids')); if ($type == 'purge') { $this->repository->purge($ids); } else { $this->repository->delete($ids); } return $this->response->message(trans('messages.success.deleted', ['Module' => trans('bankoffer::bankoffer.name')])) ->status("success") ->code(202) ->url(guard_url('bankoffer/bankoffer')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/bankoffer/bankoffer')) ->redirect(); } } /** * Restore deleted bankoffers. * * @param Model $bankoffer * * @return Response */ public function restore(BankofferRequest $request) { try { $ids = hashids_decode($request->input('ids')); $this->repository->restore($ids); return $this->response->message(trans('messages.success.restore', ['Module' => trans('bankoffer::bankoffer.name')])) ->status("success") ->code(202) ->url(guard_url('/bankoffer/bankoffer')) ->redirect(); } catch (Exception $e) { return $this->response->message($e->getMessage()) ->status("error") ->code(400) ->url(guard_url('/bankoffer/bankoffer/')) ->redirect(); } } }