belongsTo('App\Models\User', 'user_id'); } /** * 获取被邀请用户信息 * * @return BelongsTo */ public function invitedUser() { return $this->belongsTo('App\Models\User', 'invited_user_id'); } /** * 获取物品信息(如果奖励类型为物品) * * @return BelongsTo|null */ public function item() { if ($this->reward_type != self::REWARD_TYPE_ITEM) { return null; } return $this->belongsTo('App\Module\GameItems\Models\Item', 'reward_id'); } /** * 判断奖励是否已发放 * * @return bool */ public function isIssued(): bool { return $this->status == self::STATUS_ISSUED; } /** * 判断奖励是否已过期 * * @return bool */ public function isExpired(): bool { return $this->status == self::STATUS_EXPIRED; } }