12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace app\common\service;
- use app\common\constant\CommonConstant;
- use app\common\model\GoodsCategory;
- /**
- * 商品分类服务类
- */
- class GoodsCategoryService
- {
- /**
- * 商品分类列表
- *
- * @param array $where
- * @param integer $child 是否有二级:0=第一级,1=二级
- **/
- public static function get_list($where = [], $child = 0)
- {
- $list = GoodsCategory::field('is_deleted,create_at', true)
- ->where('is_deleted', CommonConstant::IS_DELETED_0)
- ->where('pid', 0)
- ->where($where);
- if ($child == 1) {
- $list->with([
- 'childlist' => function ($query) {
- $query->field('is_deleted,create_at', true);
- }
- ]);
- }
- $list = $list->order('sort desc,id asc')
- ->select();
- return $list;
- }
- }
|