eloquentClass::where('chest_id', $chestId) ->where('is_active', true) ->get(); } /** * 批量更新消耗配置的激活状态 * * @param array $ids 消耗配置ID数组 * @param bool $isActive 是否激活 * @return int 更新的记录数 */ public function batchUpdateActiveStatus(array $ids, bool $isActive): int { return $this->eloquentClass::whereIn('id', $ids) ->update(['is_active' => $isActive]); } /** * 复制消耗配置到另一个宝箱 * * @param int $sourceChestId 源宝箱ID * @param int $targetChestId 目标宝箱ID * @return int 复制的记录数 */ public function copyToAnotherChest(int $sourceChestId, int $targetChestId): int { $sourceCosts = $this->eloquentClass::where('chest_id', $sourceChestId)->get(); $count = 0; foreach ($sourceCosts as $cost) { $newCost = $cost->replicate(); $newCost->chest_id = $targetChestId; $newCost->save(); $count++; } return $count; } }