no message
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\lists\match;
|
||||
|
||||
use app\api\lists\BaseApiDataLists;
|
||||
use app\common\model\match\MatchEvent;
|
||||
use app\common\model\league\League;
|
||||
|
||||
class MatchLists extends BaseApiDataLists
|
||||
{
|
||||
private function queryWhere(): array
|
||||
{
|
||||
$where = [['is_show', '=', 1]];
|
||||
if (!empty($this->params['sport_type'])) {
|
||||
$where[] = ['sport_type', '=', $this->params['sport_type']];
|
||||
} else {
|
||||
$validSportTypes = League::where('is_show', 1)
|
||||
->where('type', 'sport')
|
||||
->where('sport_type', '>', 0)
|
||||
->column('sport_type');
|
||||
if (!empty($validSportTypes)) {
|
||||
$where[] = ['sport_type', 'in', $validSportTypes];
|
||||
}
|
||||
}
|
||||
if (!empty($this->params['league_name'])) {
|
||||
$where[] = ['league_name', '=', $this->params['league_name']];
|
||||
} elseif (empty($this->params['sport_type'])) {
|
||||
$validLeagues = League::where('is_show', 1)
|
||||
->where('type', 'league')
|
||||
->column('label');
|
||||
if (!empty($validLeagues)) {
|
||||
$where[] = ['league_name', 'in', $validLeagues];
|
||||
}
|
||||
}
|
||||
if (isset($this->params['status']) && $this->params['status'] !== '') {
|
||||
$where[] = ['status', '=', $this->params['status']];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
return MatchEvent::where($this->queryWhere())
|
||||
->field('id,league_name,league_icon,home_team,home_icon,home_score,away_team,away_icon,away_score,sport_type,status,match_time,current_minute,half_score,home_odds,draw_odds,away_odds,home_corner,away_corner,home_yellow,away_yellow,home_red,away_red,is_hot')
|
||||
->orderRaw('FIELD(status, 1, 0, 3, 2), CASE WHEN status = 2 THEN -match_time ELSE match_time END ASC')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return MatchEvent::where($this->queryWhere())->count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user