OriginalOrderModel.php 776 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App\Model;
  3. class OriginalOrderModel extends BaseModel
  4. {
  5. /**
  6. * 表名.
  7. *
  8. * @var string
  9. */
  10. protected $table = 'original_order';
  11. /**
  12. * UUID 键名
  13. * @var string
  14. */
  15. protected $uuidKeyName = 'uid';
  16. /**
  17. * 钩子函数 数据创建后
  18. */
  19. public function created()
  20. {
  21. $this->{$this->uuidKeyName} = hashEncodeId($this->id);
  22. $this->save();
  23. }
  24. public function shops()
  25. {
  26. return $this->hasOne(ShopsModel::class, 'uid', 'sell_uid');
  27. }
  28. public function buyUser()
  29. {
  30. return $this->hasOne(UserModel::class, 'code', 'buy_uid');
  31. }
  32. public function sellUser()
  33. {
  34. return $this->hasOne(UserModel::class, 'code', 'sell_uid');
  35. }
  36. }