12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace app\common\model;
- use app\common\constant\CommonConstant;
- use think\Model;
- /**
- * 商品模型
- */
- class Goods extends Model
- {
- // 表名
- protected $name = 'goods';
- // 追加属性
- protected $append = [
- ];
- // 关联商品库存 (商品列表)
- public function goodsStock()
- {
- return $this->hasMany(GoodsStock::class, 'goods_id', 'id');
- }
- // 关联商品分类一级
- public function goodsCategoryOne(){
- return $this->belongsTo(GoodsCategory::class, 'goods_category_first', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0);
- }
- // 关联商品分类
- public function goodsCategory(){
- return $this->belongsTo(GoodsCategory::class, 'goods_category_id', 'id')->where('is_deleted',CommonConstant::IS_DELETED_0);
- }
- // // 关联商品规格项 (商品列表)
- // public function goodsSku()
- // {
- // return $this->hasMany(GoodsSku::class, 'goods_id', 'id');
- // }
- //
- // // 关联商品规格值 (申请/重新发起)
- // public function goodsSkuValue()
- // {
- // return $this->hasMany(GoodsSkuValue::class, 'goods_id', 'id');
- // }
- }
|