Files
sbnews/server/app/adminapi/logic/match/MatchLogic.php
T
2026-06-11 12:15:29 +08:00

62 lines
1.6 KiB
PHP

<?php
namespace app\adminapi\logic\match;
use app\common\logic\BaseLogic;
use app\common\model\match\MatchEvent;
class MatchLogic extends BaseLogic
{
public static function detail($params): array
{
$match = MatchEvent::findOrEmpty($params['id'])->toArray();
if (!empty($match['match_time'])) {
$match['match_time_str'] = date('Y-m-d H:i', $match['match_time']);
}
return $match;
}
public static function edit(array $params): bool
{
try {
$data = ['id' => $params['id']];
$allowFields = [
'league_name',
'round_name',
'stage',
'live_url',
'home_team',
'home_icon',
'home_score',
'away_team',
'away_icon',
'away_score',
'sport_type',
'status',
'match_time',
'home_odds',
'draw_odds',
'away_odds',
'is_hot',
'is_show',
'sort',
];
foreach ($allowFields as $field) {
if (isset($params[$field])) {
$data[$field] = $params[$field];
}
}
MatchEvent::update($data);
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
public static function delete(array $params)
{
MatchEvent::destroy($params['id']);
}
}