verbanent/eloquent-binary-uuid
Store UUID primary keys as compact 16-byte binary values instead of 36-character strings. This Laravel/Eloquent package provides casts and model traits for efficient binary UUIDs, reducing storage and improving index performance.
binary-uuid.default_column is available. That config value is the column the package looks for when a model does not declare one.binary column (not char(36)), and let the creating hook generate the value. If the column is not the default (id), set $uuidColumn on the model.$uuidColumn on every model whose UUID column is not id. Rely on binary-uuid.default_column only for a single app-wide convention; per-model declarations are clearer and produce better error messages when misconfigured.binary(16) storage for index size and join performance, and convert to the canonical string form in accessors, API resources and getRouteKey(). Do not store the string form in the binary column — the package now calls that case out explicitly.foreignUuid() helper so FK columns match the referenced binary(16) type. A char(36) FK against a binary(16) PK will not join, and the failure is silent.creating hook fill it; assign only when you deliberately need a fixed UUID, and then assign the string form.bin2hex/Uuid::fromString calls. This is also the place to handle the string representation for logs and URLs.Verbanent\Uuid\Exceptions\InvalidBinaryUuidException is thrown from uuid() and foreignUuid() when the column does not hold a 16-byte binary UUID. The message names the model, the column and the byte length found, and tells you to point $uuidColumn or binary-uuid.default_column at the right column. This replaces the opaque ramsey/uuid message ($bytes string should contain 16 characters.) — treat the new message as the diagnosis, not a symptom.creating hook now rejects values it cannot encode (anything that is neither a UUID string nor 16 raw bytes) instead of passing them through. Previously MySQL outside strict mode would truncate these silently. Correctly configured models are unaffected; inserts that were already storing wrong data will now throw. Check importers and any code that sets the UUID column by hand.$model->uuid = 3 previously produced a TypeError inside ramsey/uuid because Uuid::isValid() is typed string; it now reports the real problem. If you catch exceptions around model saves, widen the catch to the package exceptions.AccessedUnsetUuidPropertyException now names the column and model too, which makes it useful for tracking down which accessor ran before the UUID was populated.binary(16) keys as mojibake or hex. Use BIN_TO_UUID() / UNHEX() in ad-hoc queries, or convert via the package's string accessor, rather than copying raw bytes around.$uuidColumn per model, set binary-uuid.default_column for the app default, and use the exception types (InvalidBinaryUuidException, AccessedUnsetUuidPropertyException) for targeted handling in tests or data-repair commands.How can I help you explore Laravel packages today?