feat: configure hot leagues in match center
This commit is contained in:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user