1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\common\model;
- use think\Model;
- /**
- * 模型
- */
- class SkuSpec extends Model
- {
- // 表名
- protected $name = 'shop_goods_sku_spec';
- // 开启自动写入时间戳字段
- protected $autoWriteTimestamp = 'int';
- // 定义时间戳字段名
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- // 追加属性
- protected $append = [];
- public function SkuValue()
- {
- return $this->hasMany('SkuSpec', 'spec_id', 'spec_id');
- }
- public function Spec()
- {
- return $this->hasOne('Spec', 'id', 'spec_id', [], 'LEFT')
- ->bind(['title' => 'name']);
- }
- public function SpecValue()
- {
- return $this->hasOne('SpecValue', 'id', 'spec_value_id', [], 'LEFT')
- ->bind([
- 'title' => 'value',
- 'image' => 'image',
- 'desc' => 'desc'
- ]);
- }
- }
|