feat: 为玩法规则 HTML 配置增加多语言设置迁移
This commit is contained in:
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\LotterySetting;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 玩法规则 HTML:由单键 frontend.play_rules_html 拆分为 zh/en/ne 三语键。
|
||||||
|
* 已有内容迁移到 frontend.play_rules_html_zh。
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
private const LEGACY_KEY = 'frontend.play_rules_html';
|
||||||
|
|
||||||
|
private const I18N_KEYS = [
|
||||||
|
'frontend.play_rules_html_zh' => '玩家端玩法规则页 HTML(中文)',
|
||||||
|
'frontend.play_rules_html_en' => '玩家端玩法规则页 HTML(English)',
|
||||||
|
'frontend.play_rules_html_ne' => '玩家端玩法规则页 HTML(नेपाली)',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$legacyRow = LotterySetting::query()->where('setting_key', self::LEGACY_KEY)->first();
|
||||||
|
$legacyValue = $legacyRow?->value_json;
|
||||||
|
|
||||||
|
foreach (self::I18N_KEYS as $key => $description) {
|
||||||
|
if (LotterySetting::query()->where('setting_key', $key)->exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = '';
|
||||||
|
if ($key === 'frontend.play_rules_html_zh' && is_string($legacyValue) && trim($legacyValue) !== '') {
|
||||||
|
$value = $legacyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
LotterySetting::query()->create([
|
||||||
|
'setting_key' => $key,
|
||||||
|
'value_json' => $value,
|
||||||
|
'group_name' => 'frontend',
|
||||||
|
'description_zh' => $description,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
LotterySetting::query()
|
||||||
|
->whereIn('setting_key', array_keys(self::I18N_KEYS))
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -93,7 +93,28 @@ final class LotterySettingsSeeder extends Seeder
|
|||||||
'frontend.play_rules_html',
|
'frontend.play_rules_html',
|
||||||
'',
|
'',
|
||||||
'frontend',
|
'frontend',
|
||||||
'玩家端玩法规则页面显示的自定义 HTML 富文本内容',
|
'玩家端玩法规则页面显示的自定义 HTML(遗留键,保存时与中文键同步)',
|
||||||
|
);
|
||||||
|
|
||||||
|
LotterySettings::put(
|
||||||
|
'frontend.play_rules_html_zh',
|
||||||
|
'',
|
||||||
|
'frontend',
|
||||||
|
'玩家端玩法规则页 HTML(中文)',
|
||||||
|
);
|
||||||
|
|
||||||
|
LotterySettings::put(
|
||||||
|
'frontend.play_rules_html_en',
|
||||||
|
'',
|
||||||
|
'frontend',
|
||||||
|
'玩家端玩法规则页 HTML(English)',
|
||||||
|
);
|
||||||
|
|
||||||
|
LotterySettings::put(
|
||||||
|
'frontend.play_rules_html_ne',
|
||||||
|
'',
|
||||||
|
'frontend',
|
||||||
|
'玩家端玩法规则页 HTML(नेपाली)',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user