id = $buff->id; $dto->userId = $buff->user_id; $dto->buffType = $buff->buff_type; $dto->buffTypeName = BUFF_TYPE::getName($buff->buff_type); $dto->description = BUFF_TYPE::getDescription($buff->buff_type); $dto->expireTime = $buff->expire_time->toDateTimeString(); $dto->createdAt = $buff->created_at->toDateTimeString(); return $dto; } /** * 转换为数组 * * @return array */ public function toArray(): array { return [ 'id' => $this->id, 'user_id' => $this->userId, 'buff_type' => $this->buffType, 'buff_type_name' => $this->buffTypeName, 'description' => $this->description, 'expire_time' => $this->expireTime, 'created_at' => $this->createdAt, ]; } }