BaseLeague.php 3.3 KB

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