sinclairt / settingable
Store settings for an app or resource in the database
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sinclairt/settingable
Requires (Dev)
- laracasts/testdummy: ^2.3
- laravel/laravel: ^5.3
- mockery/mockery: ^0.9.5
- phpspec/phpspec: ^3.1
- phpunit/phpunit: ^5.5
This package is not auto-updated.
Last update: 2025-10-26 09:50:27 UTC
README
Installation
- Run
composer require sinclairt/settable. - Register
Sinclair\Settable\SettableServiceProvider::classinconfig\app.phpinside theprovidersarray. - Run
composer dump-autoload - Run
php artisan vendor:publish. This wil publish the migration for the settings. - Run
php artisan migrate
Usage
Settings can be global or resource specific, for global settings, the $myObject in the examples below can be omitted or set to null, otherwise include the object whose setting you need.
Get
Shorthand: setting('some_key') will return the 'some_key' value. This will only return global settings, use the alternative method for resource settings
Alternative: app('Settable')->get('some_key', $myObject, 'my_default') or setting()->get(...)
It will check whether the value is a callback and return the value of the callback.
Set
Shorthand: setting(['some_key', 'some_value', $myObject]) will set the 'some_key' key to 'some_value' and return boolean.
Alternative: app('Settable')->set('some_key', 'my_value', $myObject) or setting()->set(...)
Exists
app('Settable')->exists('some_key', $myObject) or setting()->exists(...)returns boolean