getUserBuffs($userId); } catch (\Exception $e) { Log::error('获取用户神灵加持失败', [ 'user_id' => $userId, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return collect(); } } /** * 获取用户的有效神灵加持 * * @param int $userId * @return Collection */ public static function getActiveBuffs(int $userId): Collection { try { $buffLogic = new BuffLogic(); return $buffLogic->getActiveBuffs($userId); } catch (\Exception $e) { Log::error('获取用户有效神灵加持失败', [ 'user_id' => $userId, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return collect(); } } /** * 获取用户指定类型的神灵加持 * * @param int $userId * @param int $buffType * @return FarmGodBuff|null */ public static function getUserBuff(int $userId, int $buffType): ?FarmGodBuff { try { $buffLogic = new BuffLogic(); return $buffLogic->getUserBuff($userId, $buffType); } catch (\Exception $e) { Log::error('获取用户指定类型神灵加持失败', [ 'user_id' => $userId, 'buff_type' => $buffType, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return null; } } /** * 获取用户指定类型的有效神灵加持 * * @param int $userId * @param int $buffType * @return FarmGodBuff|null */ public static function getActiveUserBuff(int $userId, int $buffType): ?FarmGodBuff { try { $buffLogic = new BuffLogic(); return $buffLogic->getActiveUserBuff($userId, $buffType); } catch (\Exception $e) { Log::error('获取用户指定类型有效神灵加持失败', [ 'user_id' => $userId, 'buff_type' => $buffType, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return null; } } /** * 激活神灵加持 * * @param int $userId * @param int $buffType * @param int $durationHours * @return FarmGodBuff|null */ public static function activateBuff(int $userId, int $buffType, int $durationHours): ?FarmGodBuff { try { $buffLogic = new BuffLogic(); return $buffLogic->activateBuff($userId, $buffType, $durationHours); } catch (\Exception $e) { Log::error('激活神灵加持失败', [ 'user_id' => $userId, 'buff_type' => $buffType, 'duration_hours' => $durationHours, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return null; } } }