RecommendBanner.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\admin\model\special;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. class RecommendBanner extends ModelBasic
  15. {
  16. use ModelTrait;
  17. public static function valiWhere($alias = '', $model = null)
  18. {
  19. if (is_null($model)) $model = new self();
  20. if ($alias) {
  21. $model = $model->alias($alias);
  22. $alias .= '.';
  23. }
  24. return $model->where("{$alias}is_show", 1);
  25. }
  26. public static function getRecemmodBannerList($where)
  27. {
  28. $data = self::valiWhere()->order('sort DESC')->where('recommend_id', $where['id'])->page((int)$where['page'], (int)$where['limit'])->select();
  29. $data = count($data) ? $data->toArray() : [];
  30. foreach ($data as &$item) {
  31. $item['add_time'] = date('Y-m-d H:i:s', $item['add_time']);
  32. }
  33. $count = self::valiWhere()->order('sort DESC')->where('recommend_id', $where['id'])->count();
  34. return compact('data', 'count');
  35. }
  36. }