repository = $repository; } /** * @param string $key * @return mixed * @author xaboy * @day 2020-04-22 */ public function save($key) { $formData = $this->request->post(); if (!count($formData)) return app('json')->fail('保存失败'); /** @var ConfigClassifyRepository $make */ $make = app()->make(ConfigClassifyRepository::class); if (!($cid = $make->keyById($key))) return app('json')->fail('保存失败'); $this->repository->save($cid, $formData, $this->request->merId()); return app('json')->success('保存成功'); } /** * @param $name * @return mixed * @author xaboy * @day 2020-03-27 */ public function getByName($name) { $data = Db::name('system_config_value')->where('config_key', $name)->where('mer_id', 0)->value('value'); if (!$data) return app('json')->fail('配置不存在'); else { if (is_json($data)) { $data = json_decode($data, true); } return app('json')->success($data); } } /** * @return mixed * @author xaboy * @day 2020-04-22 */ public function saveByName() { $name = input('name'); $value = input('value'); if (!$name || !$value) return app('json')->fail('保存失败'); /** @var ConfigClassifyRepository $make */ if (in_array($name, ['commission_rate', 'invite_chuangke_rate', 'bonus_setting', 'zhitui_rate'])) { $value= json_encode($value); } Db::name('system_config_value')->where('config_key', $name)->where('mer_id', 0)->update([ 'value' => $value ]); return app('json')->success('保存成功'); } }