PaymentTypeModel.php 789 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Model;
  3. use Hyperf\Database\Model\Collection;
  4. use Hyperf\Database\Model\Model;
  5. use Hyperf\ModelCache\Cacheable;
  6. use Hyperf\ModelCache\CacheableInterface;
  7. class PaymentTypeModel extends BaseModel implements CacheableInterface
  8. {
  9. // 使用自动缓存.
  10. use Cacheable;
  11. /**
  12. * UUID 键名
  13. * @var string
  14. */
  15. protected $uuidKeyName = 'uid';
  16. /**
  17. * 表名.
  18. *
  19. * @var string
  20. */
  21. protected $table = 'payment_type';
  22. /**
  23. * 钩子函数 数据创建后
  24. */
  25. public function created()
  26. {
  27. $this->{$this->uuidKeyName} = hashEncodeId($this->id);
  28. $this->save();
  29. }
  30. public function attrs()
  31. {
  32. return $this->hasOne(PaymentAttrModel::class, 'uid', 'payment_attr_uid');
  33. }
  34. }