belongsTo(User::class, 'UserID', 'id'); } /** * 获取任务(如果是任务奖励) */ public function task() { if ($this->reward_type == 1 && $this->taskid) { return $this->belongsTo(AgentTask::class, 'taskid', 'taskid'); } return null; } /** * 获取佣金记录(如果是佣金奖励) */ public function commission() { if ($this->reward_type == 2 && $this->source_id) { return $this->belongsTo(AgentDepositCommission::class, 'source_id', 'id'); } return null; } }