| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace App\Models\Agent;
- use App\Models\BaseModel;
- use App\Models\User;
- class Agent extends BaseModel
- {
- public const STATUS_DISABLED = 0;
- public const STATUS_ENABLED = 1;
- protected $table = 'agents';
- protected $fillable = [
- 'parent_id', 'path', 'level', 'username', 'password', 'withdraw_password',
- 'real_name', 'invitation_code', 'balance', 'frozen_balance',
- 'deposit_fee_rate', 'withdraw_fee_rate', 'flow_commission_rate',
- 'profit_commission_rate', 'status', 'last_login_at', 'last_login_ip', 'created_by',
- ];
- protected $hidden = ['password', 'withdraw_password'];
- protected $casts = [
- 'parent_id' => 'integer', 'level' => 'integer', 'status' => 'integer',
- 'balance' => 'decimal:4', 'frozen_balance' => 'decimal:4',
- 'deposit_fee_rate' => 'decimal:4', 'withdraw_fee_rate' => 'decimal:4',
- 'flow_commission_rate' => 'decimal:4', 'profit_commission_rate' => 'decimal:4',
- 'last_login_at' => 'datetime',
- ];
- public function parent()
- {
- return $this->belongsTo(self::class, 'parent_id');
- }
- public function domains()
- {
- return $this->hasMany(AgentDomain::class);
- }
- public function token()
- {
- return $this->hasOne(AgentToken::class);
- }
- public function children()
- {
- return $this->hasMany(self::class, 'parent_id');
- }
- public function members()
- {
- return $this->hasMany(User::class, 'agent_id');
- }
- }
|