BaseLeague.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. ->select('st_bq_league.lg_id','st_bq_league.name_chinese','st_bq_league.area_id','st_bq_league.country_id','st_bq_league.utime')
  22. ->orderby('st_bq_league.utime','desc')
  23. ->where($where)
  24. ->paginate ($list);
  25. }else{
  26. $data = $this
  27. //->join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')
  28. ->select('st_bq_league.lg_id','st_bq_league.name_chinese','st_bq_league.area_id','st_bq_league.country_id','st_bq_league.utime')
  29. ->orderby('st_bq_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. //所有赛事
  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. }