Installation
Require the package. The service provider is auto-discovered — no manual registration:
composer require roundly-consulting/attributes-for-laravelPublish the migrations, then run them:
php artisan vendor:publish --tag="attributes-migrations"
php artisan migratePublish-only migrations
The package never loads its migrations for you. Publishing copies two timestamped files — the attributes table and the attribute_revisions audit table — into your app’s database/migrations, where you own them and can adjust the schema before migrating.
If your owner models use UUID or ULID keys, publish the config and set key_type before you migrate — the owner columns are typed when the migrations run (see Database schema & model).
Optionally publish the config file:
php artisan vendor:publish --tag="attributes-config"The only publish tags the package exposes are attributes-migrations and attributes-config.
Next steps
- Add the HasAttributes trait and contract to a model.
- Attach your first typed attribute with Attributes::for($model)->set().
- Register definitions when you want validation, defaults or constraints.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.