no message
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminapi\logic\match;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\league\League;
|
||||
|
||||
class LeagueLogic extends BaseLogic
|
||||
{
|
||||
public static function detail($params): array
|
||||
{
|
||||
return League::findOrEmpty($params['id'])->toArray();
|
||||
}
|
||||
|
||||
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,
|
||||
]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function delete(array $params)
|
||||
{
|
||||
League::destroy($params['id']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user