Goods.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\common\model;
  3. use app\common\constant\CommonConstant;
  4. use think\Model;
  5. /**
  6. * 商品模型
  7. */
  8. class Goods extends Model
  9. {
  10. // 表名
  11. protected $name = 'goods';
  12. // 追加属性
  13. protected $append = [
  14. ];
  15. // 关联商品库存 (商品列表)
  16. public function goodsStock()
  17. {
  18. return $this->hasMany(GoodsStock::class, 'goods_id', 'id');
  19. }
  20. // 关联商品分类一级
  21. public function goodsCategoryOne(){
  22. return $this->belongsTo(GoodsCategory::class, 'goods_category_first', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0);
  23. }
  24. // 关联商品分类
  25. public function goodsCategory(){
  26. return $this->belongsTo(GoodsCategory::class, 'goods_category_id', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0);
  27. }
  28. // // 关联商品规格项 (商品列表)
  29. // public function goodsSku()
  30. // {
  31. // return $this->hasMany(GoodsSku::class, 'goods_id', 'id');
  32. // }
  33. //
  34. // // 关联商品规格值 (申请/重新发起)
  35. // public function goodsSkuValue()
  36. // {
  37. // return $this->hasMany(GoodsSkuValue::class, 'goods_id', 'id');
  38. // }
  39. }