Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Auto Create Uuid

Laravel Auto Create Uuid Laravel Package

mindtwo/laravel-auto-create-uuid

Auto-fill a UUID v4 on Eloquent models when creating or replicating. Add a trait, add a uuid column, and it just works—no config. Supports custom UUID column names and ensures replicas get a fresh UUID by excluding the UUID attribute on replicate.

View on GitHub
Deep Wiki
Context7

Automatically generate UUIDs for Eloquent models on creation and replication.

Frequently asked questions about Laravel Auto Create Uuid
How do I add UUID auto-generation to an existing Laravel Eloquent model?
Use the `AutoCreateUuid` trait in your model class and add a `uuid()` column to your migration. No additional configuration is needed—the package automatically generates UUIDs on model creation or replication.
Does this package work with Laravel 9 or PHP 8.1?
No, this package requires Laravel 10–13 and PHP 8.2+. If you're using an older version, you’ll need to upgrade or find an alternative solution.
Can I customize the UUID column name beyond the default 'uuid'?
Yes, you can override the column name by defining a `$uuid_column` property or implementing the `getUuidColumn()` method in your model.
Will this package interfere with existing `replicate()` logic in my models?
No, the package explicitly excludes the UUID column during replication, ensuring replicas get a fresh UUID while preserving other attributes.
Does this package support bulk inserts or batch operations?
No, this package generates UUIDs per-model-instance during `creating` or `replicating` events. For bulk inserts, you’ll need to handle UUID generation manually.
What happens if I manually set a UUID before saving?
The package checks if the UUID is valid using Laravel’s `Str::isUuid()`. If valid, it skips auto-generation and preserves your manually set value.
Is there a performance impact when using this package?
The package adds minimal overhead since UUID generation is lightweight. For high-throughput systems, ensure your database uses a binary(16) UUID column type for optimal performance.
Can I use this with non-Eloquent models or raw database queries?
No, this package is designed specifically for Eloquent models. For raw queries or non-Eloquent operations, you’ll need to generate UUIDs manually.
Are there any known conflicts with other Laravel packages?
Potential conflicts could arise if other packages override Eloquent’s `creating` or `replicating` events. Test in a staging environment to ensure compatibility.
How do I migrate an existing table to use UUIDs without downtime?
Add a new UUID column with a default value (e.g., `uuid()->default(db_raw('(uuid())'))`), then update your application to use the new column. Use a data migration to backfill UUIDs if needed.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky