MerchantModel.php 593 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Models;
  3. class MerchantModel extends BaseModel
  4. {
  5. protected $table = 'merchant';
  6. /**
  7. * UUID 键名
  8. * @var string
  9. */
  10. protected $uuidKeyName = 'uid';
  11. protected static function boot()
  12. {
  13. parent::boot();
  14. self::created(function ($model) {
  15. $uuid = hashEncodeId($model->id);
  16. $model->{$model->uuidKeyName} = $uuid;
  17. $model->save();
  18. });
  19. }
  20. public function merchantPaymentType()
  21. {
  22. return $this->hasMany(MerchantPaymentTypeModel::class, 'merchant_uid', 'uid');
  23. }
  24. }