| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Jonlin
- * Date: 2019/3/28
- * Time: 11:34
- */
- namespace App\Models;
- use Illuminate\Support\Facades\DB;
- class BaseLeague extends BaseModel {
- protected $table = "st_bq_league";
- function getinfo($list = 10, $page, $where = '')
- {
- $source = \App\Models\Setinfo::where('id','1000')->first();
- if($source->infocontent != '混合数据'){
- $where[] = array('st_bq_local_league.source', '=', $source->infocontent);
- }
- if (is_array ($where) && count ($where) > 0){
- $data = $this
- ->join('st_bq_local_league','st_bq_league.id','=','st_bq_local_league.lg_id')
- ->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')
- ->orderby('st_bq_league.utime','desc')
- ->where($where)
- //->distinct('st_bq_league.id')
- ->paginate ($list);
- }else{
- $data = $this
- ->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')
- ->orderby('st_bq_league.utime','desc')
- //->distinct('st_bq_league.id')
- ->paginate ($list);
- }
- if (!$data) {
- return -5040000102; //无相关信息
- }
- //地区
- $area = \App\Models\StAreaCountry::where('pid','0')->get();
- // $str = '';
- // for($a=0;$a<count($area);$a++){
- // $str .= '<option value="'.$area[$a]->id.'">'.$area[$a]->name.'</option>';
- // }
- //国家
- $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
- for($i=0;$i<count($data);$i++){
- $data[$i]->lg_id = $data[$i]->id;
- if($data[$i]->status == '-1'){
- $data[$i]->league_status = '未启用';
- }
- if($data[$i]->status == '1'){
- $data[$i]->league_status = '启用';
- }
- // $data[$i]->area = '<select name="area" id="area" lay-filter="sect"><option value="-1"></option>'.$str.'</select>';
- // $data[$i]->country = '<select name="country" id="country"></select>';
- $str = 0;
- $str1 = 0;
- if($data[$i]->area_id == '0'){
- $data[$i]->area = '无';
- }else{
- for($b=0;$b<count($area);$b++){
- if($area[$b]->id == $data[$i]->area_id){
- $str = 1;
- $data[$i]->area = $area[$b]->name;
- }
- }
- if($str == 0){$data[$i]->area = '无';}
- }
- if($data[$i]->country_id == 0){
- $data[$i]->country = '无';
- }else{
- for($c=0;$c<count($country);$c++){
- if($country[$c]->id == $data[$i]->country_id){
- $str1 = 1;
- $data[$i]->country = $country[$c]->name;
- }
- }
- if($str1 == 0){$data[$i]->country = '无';}
- }
- }
- return $data->toArray();
- }
- //所有赛事
- function allleague()
- {
- $data = $this->select('lg_id','name_chinese')->get();
- if (!$data) {
- return -5040000102; //无相关信息
- }
- return $data->toArray();
- }
- //测试冠军联赛数据
- function get_league_gj_info($list = 10, $page, $where = '')
- {
- if (is_array ($where) && count ($where) > 0){
- $data = $this
- ->join('st_bq_odds','st_bq_odds.lg_id','=','st_bq_league.id')
- ->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')
- ->where($where)
- ->distinct('st_bq_league.name_chinese')
- ->orderby('st_bq_league.utime','desc')
- ->paginate ($list);
- }else{
- $data = $this
- ->join('st_bq_odds','st_bq_odds.lg_id','=','st_bq_league.id')
- ->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')
- ->distinct('st_bq_league.name_chinese')
- ->orderby('st_bq_league.utime','desc')
- ->paginate ($list);
- }
- if (!$data) {
- return -5040000102; //无相关信息
- }
- //地区
- $area = \App\Models\StAreaCountry::where('pid','0')->get();
- //国家
- $country = \App\Models\StAreaCountry::where('pid','<>','0')->get();
- for($i=0;$i<count($data);$i++){
- $data[$i]->lg_id = $data[$i]->id;
- if($data[$i]->status == '-1'){
- $data[$i]->league_status = '未启用';
- }
- if($data[$i]->status == '1'){
- $data[$i]->league_status = '启用';
- }
- $str = 0;
- $str1 = 0;
- if($data[$i]->area_id == '0'){
- $data[$i]->area = '无';
- }else{
- for($b=0;$b<count($area);$b++){
- if($area[$b]->id == $data[$i]->area_id){
- $str = 1;
- $data[$i]->area = $area[$b]->name;
- }
- }
- if($str == 0){$data[$i]->area = '无';}
- }
- if($data[$i]->country_id == 0){
- $data[$i]->country = '无';
- }else{
- for($c=0;$c<count($country);$c++){
- if($country[$c]->id == $data[$i]->country_id){
- $str1 = 1;
- $data[$i]->country = $country[$c]->name;
- }
- }
- if($str1 == 0){$data[$i]->country = '无';}
- }
- }
- return $data->toArray();
- }
- }
|