Stwqresult.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Stwqresult extends Model
  5. {
  6. protected $table = 'st_wq_result';
  7. public $timestamps = false;
  8. function resultlist($list = 10, $page, $where = '', $orwhere = '')
  9. {
  10. if (is_array ($where) && count ($where) > 0) {
  11. $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_result.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->where($where)->orwhere($orwhere)->paginate ($list);
  12. } else {
  13. $data = $this->join('st_wq_league','st_wq_result.lg_id','=','st_wq_league.id')->join('st_wq_competition','st_wq_competition.id','=','st_wq_result.match_id')->select($this->table.'.id',$this->table.'.home_player_name',$this->table.'.guest_player_name',$this->table.'.match_id','st_wq_result.first_score_player','st_wq_result.status','st_wq_result.last_score_player','st_wq_result.match_score','st_wq_result.update_time','st_wq_competition.match_time','st_wq_result.match_process',$this->table.'.home_player_score',$this->table.'.guest_player_score',$this->table.'.start_time','st_wq_league.name_chinese as saisname')->orderby('st_wq_result.id','desc')->paginate ($list);
  14. }
  15. return $data->toArray ();
  16. }
  17. //查询赛事
  18. function matchjg($match_id){
  19. $data = $this->where('match_id',$match_id)->select('id','home_team','guest_team')->first();
  20. if (!$data) {
  21. return -5040000102; //无相关信息
  22. }
  23. return $data->toArray();
  24. }
  25. //更新状态
  26. function updatestatus($field,$where,$data){
  27. $res=$this->where($field,$where)->update($data);
  28. if(!$res) {
  29. return -7020050022;//更新失败
  30. }
  31. return 1;
  32. }
  33. }
  34. ?>