Article.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. *------Create thems Model------
  4. *------SCWPHP Version 1.0.0------
  5. *------Dev Model Jions------
  6. *------Create Time 2017-06-12 05:08:18------
  7. */
  8. namespace App\Api\Model;
  9. use \System\Model;
  10. class Article extends Model {
  11. protected $table = 'article';
  12. //获取系统通知数据
  13. public static function getArticle($userInfo){
  14. if (empty($userInfo['identity'])) {
  15. Render([], '2001', lang('Common','Api') -> get('user does login'));
  16. }
  17. $where = [];
  18. $where[] = ['status','=',1];
  19. // $where[] = ['time','>',date("Y-m-d H:i:s",strtotime('-1 week'))];
  20. if (!empty($_POST['type'])) {
  21. $where[] = ['type','=',$_POST['type']];
  22. }
  23. if(!empty($_POST['id'])){
  24. $where[] = ['article.id','=',$_POST['id']];
  25. }
  26. $data = lm('article', "api")
  27. ->join('article_type','article_type.id','article.type')
  28. ->select('article.id','identity','title','content','time','author','type','article_type.cate_name','status','img','article.sort')
  29. ->where($where)
  30. ->limit(5)
  31. ->get()
  32. ->toArray();
  33. return $data;
  34. }
  35. }