find(); foreach ($configRow->value as $item) { if ($item['key'] == $key) { return false; } } $configRow->value = array_merge($configRow->value, [['key' => $key, 'value' => $value]]); $configRow->save(); Cache::tag(adminConfigModel::$cacheTag)->clear(); return true; } /** * 删除Array类型配置项的一个元素 */ public static function removeArrayItem(string $name, string $key): bool { $configRow = adminConfigModel::where('name', $name)->find(); $configRowValue = $configRow->value; foreach ($configRowValue as $iKey => $item) { if ($item['key'] == $key) { unset($configRowValue[$iKey]); } } $configRow->value = $configRowValue; $configRow->save(); Cache::tag(adminConfigModel::$cacheTag)->clear(); return true; } }