orderBy('created_at', 'asc')->get()->toArray(); return $this->json(array_map(function ($item) { $_value = json_decode($item['value']); return [ 'name' => $item['name'], 'slug' => $item['slug'], 'value' => $_value->value ?? $_value, 'unit' => $_value->unit ?? '万元', ]; }, $settings)); } public function updateStatistics(Request $request){ $input = $request->input(); foreach ($input as $key => $value){ //如果是更新图表数据 if(in_array($key, [ 'city_data_chart_nongye', 'city_data_chart_yuye', 'city_data_chart_xumuye', 'city_data_chart_lingye', 'city_data_chart_activity' ])){ if(!empty($value)){ $value = json_encode($value); }else{ $value = '{}'; } Setting::where('slug', $key)->update(['value'=>$value]); }else{//更新全市基础数据 if(Setting::where('slug', $key)->exists()){ Setting::where('slug', $key)->update(['value->value'=>$value]); } } } (new OperationLogService())->inLog(OperationType::Update, '修改-全市基础数据统计', null, $input); return $this->success(); } }