glorand/laravel-model-settings
Laravel Model Settings adds flexible per-model settings to Eloquent models, stored via field, table, or Redis drivers. Define defaults, then get, set, check, or remove settings through a simple API. Supports custom drivers, validation, and easy persistence.
9.1.0 adds a fourth storage backend: a generic cache driver that stores settings through Laravel's Cache facade, so any store configured in config/cache.php can back them.
✨ New: the cache driver
Set MODEL_SETTINGS_DRIVER=cache, or protected $settingsDriver = 'cache'; on a single model, to store settings in Memcached, DynamoDB, the database, files, or any other store from config/cache.php.
MODEL_SETTINGS_CACHE_STORE — named store, empty = the application defaultMODEL_SETTINGS_CACHE_TTL — lifetime in minutes, empty = foreverMODEL_SETTINGS_CACHE_PREFIX — storage key prefix (default c-k-)Settings are stored forever by default, because for this driver the cache is the only copy of the data rather than a layer in front of a database. The lifetime is refreshed only on write, never on read, so an expiring value will disappear even from a model whose settings are read constantly. A 0, negative or non-numeric TTL throws ModelSettingsException instead of being passed to Cache::put(), which would treat it as a delete.
⚠️ Two things to weigh before choosing this driver: anything that flushes the store (php artisan cache:clear, Cache::flush()) erases the settings of every model using it, and stores that evict under memory pressure can drop them at any time. Use the field or table driver if the settings must survive that.
🔄 Behavior change
The table, redis and cache drivers now require the model to exist in storage, not merely to have a primary key assigned. ModelSettingsException is thrown for an unsaved model even when its key was set manually, so code that used (new User(['id' => 5]))->settings()->all() as a lightweight reference read must load the model instead.
📝 Also documented in this release: the CHANGELOG now carries the previously missing 9.0.1 and 9.0.2 entries.
Full changelog: https://github.com/glorand/laravel-model-settings/compare/9.0.2...9.1.0
V9 is a major refactor that unifies the storage backends into a single, configuration-driven system. This release simplifies the API surface, reduces boilerplate, and provides better extensibility for custom drivers.
🔄 Breaking Changes Migration Required — see MIGRATION_GUIDE_8_to_9.md
Removed HasSettingsField, HasSettingsTable, HasSettingsRedis traits Removed flat settings_* config keys (env vars unchanged) Requires PHP 8.2+ and Laravel 12–13 (dropped 10/11, PHP 8.1) Mutations (set, update, delete, etc.) now persist only overrides; defaults are no longer copied into storage Validation runs against the effective (merged) result, not just persisted data table and redis drivers throw ModelSettingsException when model has no primary key Redis driver deletes the storage key on clear() instead of storing empty array
Full Changelog: https://github.com/glorand/laravel-model-settings/compare/8.0.3...8.0.4
@jamesdb made their first contribution in https://github.com/glorand/laravel-model-settings/pull/128
Full Changelog: https://github.com/glorand/laravel-model-settings/compare/8.0.0...8.0.1
Full Changelog: https://github.com/glorand/laravel-model-settings/compare/7.0.0...8.0.0
Full Changelog: https://github.com/glorand/laravel-model-settings/compare/6.0.3...7.0.0
Laravel 10 support, and dropped Laravel 9.
Full Changelog: https://github.com/glorand/laravel-model-settings/compare/4.4.1...5.0.0
fix: Parameter type
FIX: HasSettingsField now adheres to $connection override on model
default configs for a table in model_settings.php config file
GitHub actions
Console test && empty function (#54)
Check settings (exist) (#53)
Fix #50
Add support for Laravel 7 (#49)
How can I help you explore Laravel packages today?