$v) { // 判断是否在允许修改的字段中 if(!in_array($k, $allowFields, true)) { continue; } if ($k == 'apply_image' || $k == 'poster') { $v = empty($v) ? '' : FileService::setFileUrl($v); } $item = DistributionConfig::where('key', $k)->findOrEmpty(); if($item->isEmpty()) { // 没有则创建 DistributionConfig::create(['key' => $k, 'value' => $v]); continue; } // 有则更新 $item->value = $v; $item->save(); } } /** * @notes 字符串数字 转 纯数字 */ public static function stringToInteger($config) { foreach($config as $key => $value) { if (in_array($key, [ 'apply_image', 'poster', 'protocol_content' ])) { continue; } $config[$key] = (int)$value; } return $config; } }