BasketLeague.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 BasketLeague extends BaseModel {
  11. protected $table = "st_lq_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_lq_local_league.source', '=', $source->infocontent);
  18. }
  19. if (is_array ($where) && count ($where) > 0){
  20. $data = $this
  21. ->join('st_lq_local_league','st_lq_league.id','=','st_lq_local_league.lg_id')
  22. ->select('st_lq_league.id','st_lq_league.name_chinese','st_lq_league.area_id','st_lq_league.country_id','st_lq_league.status','st_lq_league.utime')
  23. ->orderby('st_lq_league.utime','desc')
  24. ->where($where)
  25. //->distinct('st_lq_league.id')
  26. ->paginate ($list);
  27. }else{
  28. $data = $this
  29. ->select('st_lq_league.id','st_lq_league.name_chinese','st_lq_league.area_id','st_lq_league.country_id','st_lq_league.status','st_lq_league.utime')
  30. ->orderby('st_lq_league.utime','desc')
  31. //->distinct('st_lq_league.id')
  32. ->paginate ($list);
  33. }
  34. if (!$data) {
  35. return -5040000102; //无相关信息
  36. }
  37. //地区
  38. $area = \App\Models\StAreaCountry::where('pid','0')->get();
  39. // $str = '';
  40. // for($a=0;$a<count($area);$a++){
  41. // $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
  42. // }
  43. //国家
  44. $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
  45. for($i=0;$i<count($data);$i++){
  46. //$data[$i]->id = $data[$i]->lg_id;
  47. if($data[$i]->status == '-1'){
  48. $data[$i]->league_status = '未启用';
  49. }
  50. if($data[$i]->status == '1'){
  51. $data[$i]->league_status = '启用';
  52. }
  53. // $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
  54. // $data[$i]->country = '<select name="country" id="country"></select>';
  55. $str = 0;
  56. $str1 = 0;
  57. if($data[$i]->area_id == '0'){
  58. $data[$i]->area = '无';
  59. }else{
  60. for($b=0;$b<count($area);$b++){
  61. if($area[$b]->id == $data[$i]->area_id){
  62. $str = 1;
  63. $data[$i]->area = $area[$b]->name;
  64. }
  65. }
  66. if($str == 0){$data[$i]->area = '无';}
  67. }
  68. if($data[$i]->country_id == 0){
  69. $data[$i]->country = '无';
  70. }else{
  71. for($c=0;$c<count($country);$c++){
  72. if($country[$c]->id == $data[$i]->country_id){
  73. $str1 = 1;
  74. $data[$i]->country = $country[$c]->name;
  75. }
  76. }
  77. if($str1 == 0){$data[$i]->country = '无';}
  78. }
  79. }
  80. return $data->toArray();
  81. }
  82. //所有联赛
  83. function allleague()
  84. {
  85. $data = $this->select('id','name_chinese')->get();
  86. if (!$data) {
  87. return -5040000102; //无相关信息
  88. }
  89. return $data->toArray();
  90. }
  91. }