Looking to hire Laravel developers? Try LaraJobs

laravel-settings maintained by pharaonic

Description
Typed, scoped application settings for Laravel: an Eloquent Setting model for global, named and per-model preferences, with explicit fallback, optional definitions and validation.
Last update
2026/11/10 10:21 (dev-develop)
License
Links
Downloads
460

Comments
comments powered by Disqus

Installation

composer require pharaonic/laravel-settings
php artisan migrate

The service provider is registered automatically, and migrate creates the settings table. An application upgrading from 1.x converts its existing table with php artisan settings:migrate-legacy instead (a dry run until --apply). Publish the configuration to change the table, cache, casting policy, or definitions:

php artisan vendor:publish --tag=settings-config

Usage

use Pharaonic\Laravel\Settings\Concerns\HasSettings;

class Company extends Model
{
    use HasSettings;
}
settings()->setValue('site.name', 'Pharaonic');      // global, type string
settings('checkout')->setValue('minimum', 100);      // named scope, type integer
$company->setSetting('timezone', 'Africa/Cairo');    // model scope, written right away

settings()->getValue('site.name');                   // 'Pharaonic'
settings('checkout')->setValue('minimum', '100');    // SettingTypeMismatchException: stays an integer

$theme = settings($branch)
    ->fallbackTo($company)
    ->fallbackToGlobal()                             // then the global scope
    ->getValue('theme', 'light');

Setting::for($company)->where('type', 'string')->get(); // plain Eloquent: Setting models

Documentation

Full documentation: Laravel Settings Documentation.

Support & Security

See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.

License

MIT. See LICENSE.