BaseLeague.php 2.7 KB

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