isMethod('post')){ $data = request()->all(); //更新config数据 $this->update($data); return $this->apiResponseSuccess('更新成功'); }else{ $configs = Config::whereIn('key',['logo','title','tel','email','address','wx_image','icp','put_on_record'])->pluck('value','key'); return $this->apiResponseSuccess('获取成功',$configs); } } /** * 更新config数据 * @param $data * @return bool */ function update($data){ foreach ($data as $key => $value ){ // 查找当前数据是否存在 if( Config::where('key', $key)->where('value', $value)->count() ){ continue; } Config::where('key', $key)->update([ 'value' => $value ]); } return true; } }