GoodsCategoryService.php 755 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\common\service;
  3. use app\common\constant\CommonConstant;
  4. use app\common\model\GoodsCategory;
  5. /**
  6. * 商品分类服务类
  7. */
  8. class GoodsCategoryService
  9. {
  10. /**
  11. * 商品分类列表
  12. **/
  13. public static function get_list()
  14. {
  15. $field = 'id,pid,name,weigh';
  16. $list = GoodsCategory::field($field)
  17. ->where('pid', 0)
  18. ->where('status', CommonConstant::IS_WHO_1)
  19. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  20. ->with([
  21. 'childlist' => function ($query) use ($field) {
  22. $query->field($field);
  23. }
  24. ])
  25. ->order('weigh desc,id asc')
  26. ->select();
  27. return $list;
  28. }
  29. }