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