St_zq_league.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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($where)
  48. ->where(function($query)use ($model_match,$search){
  49. $query->where($model_match.'.home_team','like','%'.$search.'%')
  50. ->orWhere(function($query)use ($model_match,$search) {
  51. $query->where($model_match . '.guest_team', 'like', '%' . $search . '%');
  52. });
  53. })
  54. ->get()
  55. ->toarray();
  56. return $data;
  57. }
  58. }