query()->insertGetId($data); // 更新缓存 if( $id ) $this->getConfigList(true); // 返回结果 return $id; } /** * 添加数据 * */ public function edit($id,$data) { // 写入数据表 $result = $this->query()->where(['id'=>$id])->update($data); // 更新缓存 if( $result ) $this->getConfigList(true); // 返回结果 return $result; } /** * 获取配置列表数据 * * @return Array 配置列表 */ public function getConfigList($focer =false){ // 缓存读取 $config = $focer ? [] : cache('config::list'); // 获取数据转数组 if( !$config ) { // 数据库读取 $config = $this->query()->where([['status','=',1]])->pluck('value','name')->toArray(); // 存储 cache(['config::list'=>$config]); } // 返回配置数据 return $config; } }