belongsTo(TeamReferralCode::class, 'code', 'code'); } /** * 获取邀请码所有者信息 * * @return BelongsTo */ public function codeOwner() { return $this->belongsTo('App\Models\User', 'code_owner_id'); } /** * 获取使用者信息 * * @return BelongsTo */ public function user() { return $this->belongsTo('App\Models\User', 'user_id'); } /** * 判断使用是否成功 * * @return bool */ public function isSuccess(): bool { return $this->status == self::STATUS_SUCCESS; } /** * 判断使用是否已撤销 * * @return bool */ public function isRevoked(): bool { return $this->status == self::STATUS_REVOKED; } }