Grade.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 Grade 一级分类
  16. * @package app\admin\model\special
  17. */
  18. class Grade extends ModelBasic
  19. {
  20. use ModelTrait;
  21. public static function getAll()
  22. {
  23. return self::where(['is_del' => 0,'is_show'=>1])->order('sort desc,add_time desc')->field(['name', 'id'])->select();
  24. }
  25. public static function getAllList($where)
  26. {
  27. $data = self::setWhere($where)->page((int)$where['page'], (int)$where['limit'])->select();
  28. $count = self::setWhere($where)->count();
  29. return compact('data', 'count');
  30. }
  31. public static function setWhere($where)
  32. {
  33. $model = self::order('sort desc,add_time desc')->where('is_del', 0);
  34. if ($where['cate_name'] != '') $model = $model->where('name', 'like', "%$where[cate_name]%");
  35. return $model;
  36. }
  37. public function SpecialSubject()
  38. {
  39. return $this->hasMany('SpecialSubject','grade_id');
  40. }
  41. }