GoodsCategory.php 511 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace app\common\model;
  3. use app\common\constant\CommonConstant;
  4. use think\Model;
  5. /**
  6. * 商品分类模型
  7. */
  8. class GoodsCategory extends Model
  9. {
  10. // 表名
  11. protected $name = 'goods_category';
  12. // 追加属性
  13. protected $append = [
  14. ];
  15. // 关联子分类
  16. public function childlist()
  17. {
  18. return $this->hasMany(GoodsCategory::class, 'pid', 'id')
  19. ->where('is_deleted', CommonConstant::IS_DELETED_0)
  20. ->order('sort desc,id asc');
  21. }
  22. }