Goods.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\model;
  3. use DateTimeInterface;
  4. use support\Model;
  5. class Goods extends Model
  6. {
  7. protected $table = 'goods';
  8. protected $primaryKey = 'goods_id';
  9. protected $keyType = 'string';
  10. public $incrementing = false;
  11. protected $dateFormat = 'U';
  12. const CREATED_AT = 'goods_addtimes';
  13. const UPDATED_AT = null;
  14. const LISTING_KEY_PREFIX = "GOODS:LISTING:";
  15. public function serializeDate(DateTimeInterface $date)
  16. {
  17. return $date->format('Y-m-d H:i:s');
  18. }
  19. /**
  20. * @Desc 关联分类
  21. * @Author Gorden
  22. * @Date 2024/3/28 9:36
  23. *
  24. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  25. */
  26. public function category()
  27. {
  28. return $this->hasOne(SysCategory::class, 'category_id', 'join_goods_category_id');
  29. }
  30. /**
  31. * @Desc 关联GoodsRunning
  32. * @Author Gorden
  33. * @Date 2024/3/28 10:04
  34. *
  35. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  36. */
  37. public function running()
  38. {
  39. return $this->hasOne(GoodsRunning::class, 'join_running_goods_id', 'goods_id');
  40. }
  41. }