<?php
/**
 * Created by PhpStorm.
 * User: Jimy
 * Date: 2019/4/18
 * Time: 13:59
 */
namespace App\Models;
use Illuminate\Support\Facades\DB;
class Stbqresult extends BaseModel {
    protected $table = "st_bq_result";
    public $timestamps = false;

    function getinfo($list = 10, $page, $where = '',$orwhere = '')
    {
    	if (is_array ($where) && count ($where) > 0) {
            $data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.lg_id')->select($this->table.'.id',$this->table.'.home_team',$this->table.'.guest_team',$this->table.'.match_id','st_zq_result.guest_team','st_zq_result.home_rate','st_zq_result.guest_rate','st_zq_result.first_score','st_zq_result.status','st_zq_result.last_score','st_zq_result.match_score','st_zq_result.match_winer','st_zq_result.update_time','st_zq_competition.match_time','st_zq_result.match_process',$this->table.'.home_score',$this->table.'.guest_score',$this->table.'.u_guest_score',$this->table.'.u_home_score','st_zq_league.name_chinese as saisname')->orderby('st_zq_result.id','desc')->where($where)->orwhere($orwhere)->paginate ($list);
        } else { 
        	//$data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.lg_id')->select($this->table.".home_team",$this->table.".guest_team",$this->table.".home_rate",$this->table.".guest_rate")->orderby($this->table.'.id','desc')->select()->paginate($list);
        	$data = $this->join('st_bq_league','st_bq_result.lg_id','=','st_bq_league.lg_id')->select($this->table.".*")->orderby($this->table.'.id','desc')->select()->paginate($list);
        }
        return $data->toArray ();
    }
}