GameArticle.php 678 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: cqingt
  5. * Date: 2018/6/28
  6. * Time: 11:28
  7. */
  8. namespace app\common\model;
  9. class GameArticle extends \think\Model
  10. {
  11. protected $pk = 'id';
  12. protected $table = 'nw_game_article';
  13. protected $autoWriteTimestamp = true;
  14. /**
  15. * 获取一条显示状态的,显示时间小于当前时间的最近一条文章
  16. * @return array|false|\PDOStatement|string|\think\Model
  17. */
  18. public function getRecommend()
  19. {
  20. return $this->where(['is_show' => 1, 'show_time' => ['LT', request()->time()] ])
  21. ->field(['title', 'content'])
  22. ->order('show_time', 'desc')
  23. ->find();
  24. }
  25. }