Settings
Bonfire provides a simple interface that you can use in place of calling config() to allow you to read and store
config values in the database. If the value has not been updated and saved in the database then the original value
from the config file will be used.
This allows you to save your application's default state as values in config files, all stored in version control, and still allows your users to override those settings once the site is live.
Setup
A migration is provided that will create the required settings table. It was run during by the Bonfire installation
script. No other setup is needed.
Usage
To retrieve a config value use the setting() helper method that is always loaded. Pass the class name and the
key joined with a dot:
// The same as config('App')->siteName;
$siteName = setting('App.siteName');
// or
$siteName = setting()->get('App.siteName');
In this case we used the short class name, App, which the config() method automatically locates within the
app/Config directory. If it was from a module, it would be found there. Either way, the fully qualified name
is automatically detected by the Settings class to keep values separated from config files that may share the
same name but different namespaces.
To save a value, call the set() method on the settings class, providing the dotted class name and key, and the value.
Note that boolean true/false will be converted to strings :true and :false when stored in the database, but
will be converted back into a boolean when retrieved. Arrays and objects are serialized when saved, and unserialized
when retrieved.
setting()->set('App.siteName', 'My Great Site');
Admin accent color
The admin theme's highlight color is the Site.adminAccent setting, a #rrggbb hex string that defaults to
#D9622B. Admins change it under Settings → General. To set it from code:
setting('Site.adminAccent', '#2F6FEB');
Use the admin_accent() helper to read it. The helper always returns a valid hex color and falls back to the default
when the stored value isn't one.