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