yadakhov/insert-on-duplicate-key
INSERT ... ON DUPLICATE KEY UPDATE operations in Laravel, reducing race conditions and eliminating the need for manual SELECT + UPDATE workflows. Critical for high-concurrency systems (e.g., inventory, reservations, analytics pipelines).Adopt if:
ON DUPLICATE KEY logic like triggers).Look elsewhere if:
upsert() (v8+) or Doctrine DBAL (if not Laravel-native).updateOrCreate() is sufficient for simple cases).For Executives: "This Laravel package lets us handle ‘upsert’ operations (insert-or-update) in MySQL with a single atomic query, cutting duplicate data risks and reducing backend complexity. For example, in our e-commerce system, it’ll prevent race conditions when users add items to cart simultaneously—saving dev time and improving scalability. It’s a lightweight, battle-tested solution (used by 276+ projects) that aligns with our Laravel stack, with minimal maintenance overhead. The cost? Zero—it’s MIT-licensed and requires no new infrastructure."
For Engineering:
*"The InsertOnDuplicateKey trait wraps MySQL’s ON DUPLICATE KEY UPDATE in an Eloquent-friendly way. Key benefits:
SELECT + UPDATE patterns with a single query.updateFields.SET column = VALUES(column) + 1 for counters).
Tradeoff: MySQL-only, and the last release was 2021 (but it’s stable and MIT). For new projects, this is a no-brainer; for legacy systems, we’d need to audit conflict-handling needs first."*How can I help you explore Laravel packages today?