St_zq_league.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 getRollLeagueData($source,$models,$where,$search=''){
  14. $model_match = $models['model_match'];
  15. $model_league = $models['model_league'];
  16. $model_result = $models['model_result'];
  17. //当前状态下所有联赛
  18. $data = lm($model_league,"Sports")
  19. ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
  20. ->join($model_result,$model_result.'.match_id',$model_match.'.match_id')
  21. ->select($model_league.'.lg_id',$model_league.'.name_chinese as leagueName')
  22. ->distinct($model_league.'.name_chinese')
  23. ->where($model_league.'.source',$source['source'])
  24. ->where([[$model_league.'.name_chinese','!=','']])
  25. ->where($where)
  26. ->where(function($query)use ($model_match,$search){
  27. $query->where($model_match.'.home_team','like','%'.$search.'%')
  28. ->orWhere(function($query)use ($model_match,$search) {
  29. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  30. });
  31. })
  32. ->get()
  33. ->toarray();
  34. return $data;
  35. }
  36. //获取即将 联赛数据
  37. public static function getSoonLeagueData($source,$models,$where,$search=''){
  38. $model_match = $models['model_match'];
  39. $model_league = $models['model_league'];
  40. $model_result = $models['model_result'];
  41. //当前状态下所有联赛
  42. $data = lm($model_league,"Sports")
  43. ->join($model_match,$model_match.'.lg_id',$model_league.'.lg_id')
  44. ->select($model_league.'.lg_id',$model_league.'.name_chinese as leagueName')
  45. ->distinct($model_league.'.name_chinese')
  46. ->where($model_league.'.source',$source['source'])
  47. ->where([[$model_league.'.name_chinese','!=','']])
  48. ->where($where)
  49. ->where(function($query)use ($model_match,$search){
  50. $query->where($model_match.'.home_team','like','%'.$search.'%')
  51. ->orWhere(function($query)use ($model_match,$search) {
  52. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  53. });
  54. })
  55. ->get()
  56. ->toarray();
  57. return $data;
  58. }
  59. }