AgentBankInfoModel.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace App\Models\Mysql;
  3. class AgentBankInfoModel extends BaseMysql
  4. {
  5. /**
  6. * 表名
  7. * @var string
  8. */
  9. public $table = 'agent_bank_info';
  10. /**
  11. * UUID 键名
  12. * @var string
  13. */
  14. protected $uuidKeyName = 'uid';
  15. protected $appends = ['type_name'];
  16. /**
  17. * The "booted" method of the model.
  18. *
  19. * @return void
  20. */
  21. protected static function boot()
  22. {
  23. parent::boot();
  24. self::creating(function ($model) {
  25. $model->{$model->uuidKeyName} = self::generateId($model->uuidKeyName);
  26. });
  27. self::created(function ($model) {
  28. $uuid = hashEncodeId($model->id);
  29. $model->{$model->uuidKeyName} = $uuid;
  30. $model->save();
  31. });
  32. }
  33. public $typeMap = [
  34. 1 => '银行卡',
  35. 2 => 'USTD',
  36. 3 => '支付宝',
  37. ];
  38. /**
  39. * 获取提现方式
  40. *
  41. * @param $value
  42. * @return string
  43. */
  44. public function getTypeNameAttribute($value)
  45. {
  46. $name = $this->typeMap[$this->type] ?? '';
  47. return $this->type_name = $name;
  48. }
  49. }