SoccerLeague.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jonlin
  5. * Date: 2019/3/29
  6. * Time: 9:27
  7. */
  8. namespace App\Models;
  9. use Illuminate\Support\Facades\DB;
  10. class SoccerLeague extends BaseModel {
  11. protected $table = "st_zq_league";
  12. public $timestamps = false;
  13. function getinfo($list = 10, $page, $where = '')
  14. {
  15. // $source = \App\Models\Setinfo::where('id','1000')->first();
  16. // if($source->infocontent != '混合数据'){
  17. // $where[] = array('st_zq_local_league.source', '=', $source->infocontent);
  18. // }
  19. if (is_array ($where) && count ($where) > 0){
  20. $data = $this
  21. //->join('st_zq_local_league','st_zq_league.lg_id','=','st_zq_local_league.lg_id')
  22. ->select('st_zq_league.lg_id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.utime')
  23. ->orderby('st_zq_league.utime','desc')
  24. ->where($where)
  25. ->paginate ($list);
  26. }else{
  27. $data = $this
  28. ->select('st_zq_league.lg_id','st_zq_league.name_chinese','st_zq_league.area_id','st_zq_league.country_id','st_zq_league.utime')
  29. ->orderby('st_zq_league.utime','desc')
  30. ->paginate ($list);
  31. }
  32. if (!$data) {
  33. return -5040000102; //无相关信息
  34. }
  35. //地区
  36. $area = \App\Models\StAreaCountry::where('pid','0')->get();
  37. // $str = '';
  38. // for($a=0;$a<count($area);$a++){
  39. // $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
  40. // }
  41. //国家
  42. $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
  43. for($i=0;$i<count($data);$i++){
  44. $data[$i]->id = $data[$i]->lg_id;
  45. if($data[$i]->status == '-1'){
  46. $data[$i]->league_status = '未启用';
  47. }
  48. if($data[$i]->status == '1'){
  49. $data[$i]->league_status = '启用';
  50. }
  51. // $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
  52. // $data[$i]->country = '<select name="country" id="country"></select>';
  53. $str = 0;
  54. $str1 = 0;
  55. if($data[$i]->area_id == '0'){
  56. $data[$i]->area = '无';
  57. }else{
  58. for($b=0;$b<count($area);$b++){
  59. if($area[$b]->id == $data[$i]->area_id){
  60. $str = 1;
  61. $data[$i]->area = $area[$b]->name;
  62. }
  63. }
  64. if($str == 0){$data[$i]->area = '无';}
  65. }
  66. if($data[$i]->country_id == 0){
  67. $data[$i]->country = '无';
  68. }else{
  69. for($c=0;$c<count($country);$c++){
  70. if($country[$c]->id == $data[$i]->country_id){
  71. $str1 = 1;
  72. $data[$i]->country = $country[$c]->name;
  73. }
  74. }
  75. if($str1 == 0){$data[$i]->country = '无';}
  76. }
  77. }
  78. return $data->toArray();
  79. }
  80. //所有赛事id
  81. function allleague()
  82. {
  83. $data = $this->select('lg_id','name_chinese')->get();
  84. if (!$data) {
  85. return -5040000102; //无相关信息
  86. }
  87. return $data->toArray();
  88. }
  89. //赛事信息
  90. function onlyleague($lg_id){
  91. $data=$this->where('lg_id',$lg_id)->first();
  92. if (!$data) {
  93. return -5040000102; //无相关信息
  94. }
  95. return $data->toArray();
  96. }
  97. }