BaseLeague.php 3.1 KB

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