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
@@ -59,6 +59,7 @@ class LeagueLists extends BaseAdminDataLists implements ListsSearchInterface
'icon' => $sport['icon'] ?? '',
'sort' => $sport['sort'],
'is_show' => $sport['is_show'],
'is_hot' => 0,
'is_group' => true,
'children' => $children,
];
@@ -86,6 +87,7 @@ class LeagueLists extends BaseAdminDataLists implements ListsSearchInterface
'icon' => '',
'sort' => '',
'is_show' => '',
'is_hot' => '',
'is_group' => true,
'children' => $orphans,
];
@@ -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());
@@ -8,10 +8,12 @@ class LeagueValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'is_hot' => 'in:0,1',
];
protected $message = [
'id.require' => '联赛id不能为空',
'is_hot.in' => '热门联赛状态值错误',
];
public function sceneDetail()
@@ -21,7 +23,7 @@ class LeagueValidate extends BaseValidate
public function sceneEdit()
{
return $this->only(['id']);
return $this->only(['id', 'is_hot']);
}
public function sceneDelete()