ServerInfo.php 943 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\common\model;
  3. /**
  4. * 开服开测表
  5. * @author Administrator
  6. */
  7. class ServerInfo extends \think\Model
  8. {
  9. protected $pk = 'id';
  10. protected $table = 'cy_serverinfo';
  11. protected $dateFormat = false; //时间戳格式不自动转换
  12. public function game()
  13. {
  14. return $this->belongsTo('Game', 'gameid', 'id');
  15. }
  16. public function getServerList($where,$order='',$whereor='')
  17. {
  18. if (empty($order)){
  19. $order = 'sertime desc';
  20. }
  21. if (empty($whereor)){
  22. return ServerInfo::with(['game'=>function($query){
  23. $query->field('id,name');
  24. }])->where($where)->order($order)->paginate(20);
  25. }else{
  26. return ServerInfo::with(['game'=>function($query){
  27. $query->field('id,name');
  28. }])->where($where)->whereOr($whereor)->order($order)->paginate(20);
  29. }
  30. }
  31. }