sebastiansulinski/laravel-bits
Laravel Bits is a lightweight collection of small, reusable utilities and helpers for Laravel applications. It provides handy building blocks for common development tasks, helping you keep code concise and organized without adding heavy dependencies.
updateMany macro lets a single statement assign different values to different rows (order statuses, per-tenant limits, price tiers, re-synced inventory). That underwrites admin bulk-edit screens, import/reconciliation jobs, and webhook-driven state fan-out without N round-trips or hand-written CASE WHEN SQL.updateMany emitted MySQL backticks and unquoted identifiers, so it was effectively MySQL-only. v1.5.4 makes it grammar-aware, which means a PostgreSQL migration (or a multi-engine support commitment) is no longer blocked by this dependency. If Postgres is on the roadmap, this release is the minimum viable version — do not ship on earlier ones.CASE-expression builders, chunked update loops, and ad-hoc raw SQL. Scope is narrow (query-builder macros plus an AsBoolean cast), so the buy decision is low-cost and reversible.order, group, key) are now safe. This widens adoption to legacy or third-party schemas we don't fully control.ELSE branch was not cosmetic: records absent from a given set had columns overwritten with NULL, or the statement failed outright on non-nullable integer/timestamp columns. Any prior use of multi-set updateMany should be treated as potentially corrupting and audited.Consider it when:
whereIn(...)->update([...]) is the right tool and this package adds nothing.AsBoolean cast alongside the query macros; the multi-engine test suite now exercises it too, which is a modest maturity signal for that piece.Look elsewhere when:
upsert(); this is an update-only macro.CASE-based statement grows with the row count; confirm parameter/binding limits on your engine and plan to chunk. The release notes don't address statement-size limits.LARAVEL_BITS_TEST_PGSQL_URL / LARAVEL_BITS_TEST_MYSQL_URL are set. Confirm the maintainer's own CI sets them; if not, the "tested on Postgres and MySQL" claim describes capability, not a guarantee. The grammar-compilation checks (no server required) are the more reliable signal and do run unconditionally.For executives (one paragraph): We evaluated a small Laravel add-on that enables efficient bulk updates — changing many records to different values in a single database statement. Its value is mundane but real: it removes a recurring category of hand-written SQL from our codebase and cuts database round-trips on bulk operations. The latest release fixes genuine correctness defects that made it unusable outside MySQL, and in one case could silently null out data. Net position: low cost, low lock-in, worth a timeboxed trial; not a strategic bet.
For engineering: v1.5.4 is a correctness release, not a feature release. Three fixes matter: grammar-based identifier quoting (Postgres no longer rejects the statement, and reserved-word columns work everywhere), an ELSE branch per CASE (prevents NULL overwrite and untyped-binding failures on Postgres integer/timestamp columns, and fixes multi-set updates that touch disjoint row sets), and table-prefix awareness. Cross-engine test coverage was added but is conditional on environment variables — we should verify it actually runs upstream and add our own integration test against our target engine, our prefixed schema, and at least one reserved-word column before depending on it.
Recommendation: Adopt behind a one-sprint spike. Pin ^1.5.4 and treat anything earlier as unsafe for Postgres. Audit any existing call sites that pass multiple sets to updateMany for rows that may have been set to NULL. Wrap usage in a thin internal helper so the dependency stays swappable, and confirm chunking strategy for large batches, since statement size scales with row count.
How can I help you explore Laravel packages today?