RuleAddedComponent.php 835 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class RuleAddedComponent extends Model
  6. {
  7. protected $table = 'rule_added_component';
  8. protected $primaryKey = 'rule_added_component_id';
  9. protected $dateFormat = 'U';
  10. const CREATED_AT = 'rule_added_component_addtimes';
  11. const UPDATED_AT = null;
  12. protected function serializeDate(DateTimeInterface $date)
  13. {
  14. return $date->format('Y-m-d H:i:s');
  15. }
  16. public function goods()
  17. {
  18. return $this->hasOne(Goods::class, 'goods_id', 'rule_added_component_goods_id')
  19. ->select('goods_id', 'goods_name');
  20. }
  21. public function sku()
  22. {
  23. return $this->hasOne(GoodsSku::class, 'goods_sku_id', 'rule_added_component_goods_sku_id')
  24. ->select('goods_sku_id', 'goods_sku_specs_json');
  25. }
  26. }