SpecialSubject.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. /**
  15. * Class SpecialSubject 二级分类
  16. * @package app\admin\model\special
  17. */
  18. class SpecialSubject extends ModelBasic
  19. {
  20. use ModelTrait;
  21. public static function get_subject_list($where){
  22. $data=self::setWhere($where)->page((int)$where['page'],(int)$where['limit'])->select();
  23. foreach ($data as &$item){
  24. $item['grade_name']=Grade::where('id',$item['grade_id'])->where('is_del',0)->value('name');
  25. $item['add_time']=date('Y-m-d H:i:s',$item['add_time']);
  26. $item['special_count']=Special::PreWhere()->where('subject_id',$item['id'])->count();
  27. }
  28. $count=self::setWhere($where)->count();
  29. return compact('data','count');
  30. }
  31. public static function setWhere($where){
  32. $model=self::order('sort desc,add_time desc')->where('is_del',0);
  33. if($where['name']) $model=$model->where('name','like',"%$where[name]%");
  34. if($where['pid']) $model=$model->where('grade_id',$where['pid']);
  35. return $model;
  36. }
  37. public static function getSubjectAll(){
  38. return self::order('sort desc,add_time desc')->where(['is_show'=>1,'is_del'=>0])->field('name,id')->select();
  39. }
  40. }