ShopGoods.php 696 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\common\model\shops;
  3. use app\common\model\BaseModel;
  4. /**
  5. * ShopGoods模型
  6. * Class ShopGoods
  7. * @package app\common\model\shops
  8. */
  9. class ShopGoods extends BaseModel
  10. {
  11. protected $name = 'shop_goods';
  12. protected $type = [
  13. 'goods_category_ids' => 'array',
  14. 'goods_banners' => 'array',
  15. 'custom_attribute_items' => 'array'
  16. ];
  17. public function goodsCategory()
  18. {
  19. return $this->hasOne(ShopCategory::class, 'id', 'goods_category_id')
  20. ->field('id,name,picture');
  21. }
  22. public function goodSpecsInventory()
  23. {
  24. return $this->hasMany(ShopGoodSpecsInventory::class, 'shop_goods_id', 'id');
  25. }
  26. }