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