feat: configure hot leagues in match center

This commit is contained in:
hajimi
2026-08-02 02:50:40 +08:00
parent 3e95fad23f
commit 163df0cf85
11 changed files with 109 additions and 67 deletions
@@ -15,13 +15,24 @@ class LeagueLogic extends BaseLogic
public static function edit(array $params): bool
{
try {
League::update([
'id' => $params['id'],
'label' => $params['label'],
'icon' => $params['icon'] ?? '',
'sort' => $params['sort'] ?? 0,
'is_show' => $params['is_show'] ?? 1,
]);
$league = League::findOrEmpty($params['id']);
if ($league->isEmpty()) {
self::setError('联赛不存在');
return false;
}
$data = [];
foreach (['label', 'icon', 'sort', 'is_show'] as $field) {
if (array_key_exists($field, $params)) {
$data[$field] = $params[$field];
}
}
if (array_key_exists('is_hot', $params)) {
$data['is_hot'] = $league->type === 'league' ? (int)$params['is_hot'] : 0;
}
if (!empty($data)) {
$league->save($data);
}
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());