Goods.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. public function serializeDate(DateTimeInterface $date)
  15. {
  16. return $date->format('Y-m-d H:i:s');
  17. }
  18. /**
  19. * @Desc 关联分类
  20. * @Author Gorden
  21. * @Date 2024/3/28 9:36
  22. *
  23. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  24. */
  25. public function category()
  26. {
  27. return $this->hasOne(SysCategory::class, 'category_id', 'join_goods_category_id');
  28. }
  29. /**
  30. * @Desc 关联GoodsRunning
  31. * @Author Gorden
  32. * @Date 2024/3/28 10:04
  33. *
  34. * @return \Illuminate\Database\Eloquent\Relations\HasOne
  35. */
  36. public function running()
  37. {
  38. return $this->hasOne(GoodsRunning::class, 'join_running_goods_id', 'goods_id');
  39. }
  40. }