SpecialSource.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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\special;
  12. use traits\ModelTrait;
  13. use basic\ModelBasic;
  14. /**
  15. * Class Special 专题素材关联表
  16. * @package app\admin\model\special
  17. */
  18. class SpecialSource extends ModelBasic
  19. {
  20. use ModelTrait;
  21. /**获取专题素材
  22. * @param bool $special_id
  23. * @return false|\PDOStatement|string|\think\Collection
  24. * @throws \think\db\exception\DataNotFoundException
  25. * @throws \think\db\exception\ModelNotFoundException
  26. * @throws \think\exception\DbException
  27. */
  28. public static function getSpecialSource($special_id = false, $source_id = false, $limit = false, $page = false)
  29. {
  30. $where = array();
  31. $data = self::where($where);
  32. if ($special_id) {
  33. if (is_array($special_id)) {
  34. $data->whereIn('special_id', $special_id);
  35. }else{
  36. $where['special_id'] = $special_id;
  37. $data->where($where);
  38. }
  39. }
  40. if ($source_id) {
  41. if (!is_array($source_id)) {
  42. $where['source_id'] = $source_id;
  43. $data->where($where);
  44. } else {
  45. $data->whereIn('source_id', $source_id);
  46. }
  47. }
  48. if ($page) {
  49. $data->page($page, !$limit ? 10 : $limit);
  50. }
  51. return $data->order('sort DESC')->select();
  52. }
  53. }