St_zq_league.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Sports\Model;
  3. use \System\Model;
  4. /**
  5. * Class Account
  6. * @package App\Sports\Model
  7. * 用户账号
  8. */
  9. class St_zq_league extends Model
  10. {
  11. protected $table = 'st_zq_league';
  12. //获取各状态下 联赛数据
  13. public static function getLeagueData($source,$models,$where,$search=''){
  14. $model_match = $models['model_match'];
  15. $model_odds = $models['model_odds'];
  16. $model_league = $models['model_league'];
  17. $model_result = $models['model_result'];
  18. //当前状态下所有联赛
  19. $data = lm($model_league,"Sports")
  20. ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
  21. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  22. ->select($model_league.'.lg_id',$model_league.'.name_chinese as leagueName')
  23. ->distinct($model_league.'.name_chinese')
  24. ->where($model_league.'.source',$source['source'])
  25. ->where([[$model_league.'.name_chinese','!=','']])
  26. ->where($where)
  27. ->where(function($query)use ($model_match,$search){
  28. $query->where($model_match.'.home_team','like','%'.$search.'%')
  29. ->orWhere(function($query)use ($model_match,$search) {
  30. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  31. });
  32. })
  33. ->get()
  34. ->toarray();
  35. return $data;
  36. }
  37. }