Article.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\wap\model\article;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. /**
  15. * Class Search
  16. * @package app\wap\model
  17. */
  18. class Article extends ModelBasic
  19. {
  20. use ModelTrait;
  21. public static function PreWhere($alias='',$model=null){
  22. if(is_null($model)) $model=new self();
  23. if($alias){
  24. $model->alias($alias);
  25. $alias.='.';
  26. }
  27. return $model->where(["{$alias}is_show"=>1,"{$alias}hide"=>0]);
  28. }
  29. public static function getLabelAttr($value){
  30. return is_string($value) ? json_decode($value,true) : $value;
  31. }
  32. /**
  33. * 活动列表
  34. */
  35. public static function getUnifiendList($where){
  36. $model=self::PreWhere();
  37. if($where['cid']) $model=$model->where('cid',$where['cid']);
  38. $list=$model->page((int)$where['page'],(int)$where['limit'])->order('sort DESC,add_time DESC')->select();
  39. $list=count($list) >0 ? $list->toArray() : [];
  40. foreach ($list as &$item){
  41. $item['add_time']=date('Y-m-d H:i',$item['add_time']);
  42. $item['synopsis']=mb_substr($item['synopsis'],0,18,'utf-8');
  43. }
  44. return $list;
  45. }
  46. }