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