{$model->uuidKeyName} = self::generateId($model->uuidKeyName); }); self::created(function ($model) { $uuid = hashEncodeId($model->id); $model->{$model->uuidKeyName} = $uuid; $model->save(); }); } public $typeMap = [ 1 => '银行卡', 2 => 'USDT', 3 => '支付宝', ]; protected $appends = ['pay_amount', 'type_name']; /** * 提现方式翻译 * * @param $value * @return string */ public function getTypeNameAttribute($value) { $value = $this->typeMap[$this->type] ?? ''; return $value; } /** * 实际支付金额 * * @param $value * @return int|mixed */ public function getPayAmountAttribute($value) { if ($this->type == 2) { $payAmount = round($this->amount / $this->usdt_rate); $value = $payAmount . "($this->amount)"; } else { $value = $this->amount; } return $value; } public function agent() { return $this->hasOne(AgentModel::class, 'uid', 'agent_uid'); } }