123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- <?php
- declare (strict_types=1);
- namespace app\common\model;
- use think\Paginator;
- use think\model\Collection;
- use app\common\library\helper;
- use app\store\model\GoodsCategoryRel as GoodsCategoryRelModel;
- use app\common\enum\goods\Status as GoodsStatusEnum;
- use think\facade\Db;
- /**
- * 门店自提商品模型
- * Class ShopGoods
- * @package app\common\model
- */
- class ShopGoods extends BaseModel
- {
- // 定义表名
- protected $name = 'shop_goods';
- // 定义主键
- protected $pk = 'id';
- // 追加字段
- protected $append = [];
- public function goods()
- {
- return $this->belongsTo("Goods")->with(['images' => ['file']]);
- }
- /**
- * 关联门店商品规格表
- * @return \think\model\relation\HasMany
- */
- public function shopGoodsSku()
- {
- return $this->hasMany('ShopGoodsSku', 'shop_goods_id')
- ->order(['id' => 'asc']);
- }
- /**
- * 关联商品图片表
- * @return \think\model\relation\HasMany
- */
- public function images()
- {
- return $this->hasMany('GoodsImage')->order(['id']);
- }
- public function shops()
- {
- return $this->hasOne('Shops', 'shop_id', 'shop_id');
- }
-
- }
|