| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- <?php
- namespace App\Model;
- use Hyperf\Database\Model\Collection;
- use Hyperf\Database\Model\Model;
- use Hyperf\ModelCache\Cacheable;
- use Hyperf\ModelCache\CacheableInterface;
- class PaymentTypeModel extends BaseModel implements CacheableInterface
- {
- // 使用自动缓存.
- use Cacheable;
- /**
- * UUID 键名
- * @var string
- */
- protected $uuidKeyName = 'uid';
- /**
- * 表名.
- *
- * @var string
- */
- protected $table = 'payment_type';
- /**
- * 钩子函数 数据创建后
- */
- public function created()
- {
- $this->{$this->uuidKeyName} = hashEncodeId($this->id);
- $this->save();
- }
- public function attrs()
- {
- return $this->hasOne(PaymentAttrModel::class, 'uid', 'payment_attr_uid');
- }
- }
|