'合营', self::TYPE_EQUITY => '入股']; protected $table = 'agents'; protected $fillable = [ 'parent_id', 'path', 'level', 'username', 'password', 'withdraw_password', 'real_name', 'language', 'invitation_code', 'balance', 'frozen_balance', 'deposit_fee_rate', 'withdraw_fee_rate', 'profit_commission_rate', 'status', 'last_login_at', 'last_login_ip', 'created_by', 'profit_commission_profile_id', 'type', ]; // realtime_balance 是系统内部的实时保证金依据,不对代理端返回。 protected $hidden = ['password', 'withdraw_password', 'realtime_balance']; protected $appends = ['type_text']; protected $casts = [ 'owner_user_id' => 'integer', 'parent_id' => 'integer', 'level' => 'integer', 'status' => 'integer', 'type' => 'integer', 'balance' => 'decimal:4', 'frozen_balance' => 'decimal:4', 'margin_amount' => 'decimal:4', 'realtime_balance' => 'decimal:4', 'profit_active' => 'integer', 'profit_active_changed_at' => 'datetime', 'equity_percent' => 'decimal:4', 'deposit_fee_rate' => 'decimal:4', 'withdraw_fee_rate' => 'decimal:4', 'profit_commission_rate' => 'decimal:4', 'last_login_at' => 'datetime', 'profit_commission_profile_id' => 'integer', ]; public function domains() { return $this->hasMany(AgentDomain::class); } public function token() { return $this->hasOne(AgentToken::class); } public function members() { return $this->hasMany(User::class, 'agent_id'); } public function profitCommissionProfile() { return $this->belongsTo(AgentProfitCommissionProfile::class, 'profit_commission_profile_id'); } public function profitCommissionAssignments() { return $this->hasMany(AgentProfitCommissionAssignment::class); } public function isJoint(): bool { return (int) $this->type === self::TYPE_JOINT; } public function isEquity(): bool { return (int) $this->type === self::TYPE_EQUITY; } public function getTypeTextAttribute(): string { return self::TYPE_NAMES[(int) ($this->type ?: self::TYPE_JOINT)] ?? ''; } }