Weave 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 Polymorphic Settings

Laravel Polymorphic Settings Laravel Package

sitesource/laravel-polymorphic-settings

Laravel Polymorphic Settings lets you attach flexible key-value settings to any Eloquent model through a polymorphic relationship, with a simple API for storing, retrieving, updating, and managing configuration-like data per record.

View on GitHub
Deep Wiki
Context7

Polymorphic, per-model key-value settings for Laravel with opt-in encryption and transparent caching.

Frequently asked questions about Laravel Polymorphic Settings
What is sitesource/laravel-polymorphic-settings used for?
It adds polymorphic key-value settings to Eloquent models, so each model instance can have its own configurable options without schema changes. Settings are stored per model and can be encrypted and cached transparently. It is aimed at Laravel applications that need runtime, per-record configuration.
How do I install sitesource/laravel-polymorphic-settings?
Install it with Composer using composer require sitesource/laravel-polymorphic-settings. Then follow the README to publish any config and migration files and run php artisan migrate. Laravel package discovery should register the service provider automatically, but verify the exact publish tags in the repository README.
Which Laravel and PHP versions are supported?
The Composer constraints in the package define the supported Laravel and PHP versions, so check them before installing. Because the package is distributed on Packagist, Composer will fail if your application does not meet those constraints. Review the README and composer.json for the current support matrix.
How do I add settings to an Eloquent model?
You typically attach the package's settings trait to the model that should own settings. The polymorphic relationship then lets each model instance store and retrieve its own key-value pairs. See the README for the exact trait name and available methods.
Does it support encryption of setting values?
Yes, encryption is opt-in, so you can choose which settings or models are encrypted. Encrypted values are handled transparently through Laravel's encryption facilities, so you read and write normal values. Use a stable APP_KEY and plan for key rotation before encrypting production data.
How does caching work and how do I clear it?
The package provides transparent caching, meaning reads can be served from your configured Laravel cache store. When settings change, the package should invalidate the relevant cache entries automatically. If you need to force a refresh, clear the application cache or the package's cache keys according to the README.
Can I store arrays or JSON values, or only strings?
The package stores key-value settings, and typical implementations serialize non-scalar values so you can store arrays or structured data. Check the README for the exact casting and serialization behavior. For complex schemas, consider whether dedicated columns or a typed settings package is a better fit.
How is this different from spatie/laravel-settings?
Spatie's package focuses on typed settings classes, often application-wide or scoped, with DTO-style access. This package focuses on polymorphic per-model key-value settings with opt-in encryption and transparent caching. Choose this one when settings belong to individual Eloquent records rather than global configuration.
How should I test models that use these settings?
Use Laravel's normal testing tools and refresh the database between tests so settings rows do not leak. If caching is enabled, clear or fake the cache in setUp or use any documented test helpers. Assert both the stored value and the decrypted or cast value your application reads.
What are production concerns for per-model settings?
Watch cache invalidation across multiple app servers and use a shared cache store such as Redis or Memcached if settings change often. Encrypted settings depend on APP_KEY, so include key rotation and backups in your operational plan. Also consider query performance if you filter or sort models by setting values.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections