Basic Usage
Basic Usage
Table of Contents
{note} You're browsing the documentation for an old version of laravel-settings. Consider upgrading your project to v3. Check your version with the following command:
composer show rawilk/laravel-settings
- Introduction
- Setting a value
- Retrieving a value
- Check if a setting exists
- Remove a setting from storage
- Boolean settings
Introduction
You can interact with settings via the Settings
facade, or by using the settings()
helper function, which returns an instance of Rawilk\Settings\Settings
.
Setting a value
// Create a new setting
Settings::set('foo', 'bar');
// Update an existing setting
Settings::set('foo', 'updated value');
Retrieving a value
Settings::get('foo');
// Retrieve a non-persisted setting
Settings::get('not persisted', 'my default'); // 'my default'
Check if a setting exists
Settings::has('foo');
Remove a setting from storage
Settings::forget('foo');
Boolean settings
Settings::set('app.debug', true);
Settings::isTrue('app.debug'); // true
Settings::isFalse('app.debug'); // false
Settings::set('app.debug', false);
Settings::isFalse('app.debug'); // true