Adds simple settings to any Laravel application.
Define setting types in config/laravel-settings.php
, these are simply stored along with each setting.
Define type casts in the above config file, setting values will automatically be casted to their native types on retrieval!
return [
// ...
'casts' => [
'boolean' => 'bool',
'select' => 'array',
'json' => 'json',
'number' => 'int',
],
// ...
];
- Using the helper
setting('setting_group.key');
- Using the facade
\LaraPkg\Settings\Facades\Setting::get('setting_group.key');
- With an Entity id An entity id allows you to store specific settings for that entity (such as a Domain or multi-tenant application)
$entityId = 1;
\LaraPkg\Settings\Facades\Setting::get('setting_group.key', $entityId);
- Using the helper
set_setting('setting_group.key', 'Some value!');
- Using the Facade
$value = 'something to store';
$entityId = 1 ?? null;
$groupName = 'setting_group' ?? null;
\LaraPkg\Settings\Facades\Setting::set('key', $value, $groupName, $entityId);
composer require larapkg/laravel-settings
php artisan vendor:publish --provider="LaraPkg\Settings\SettingsServiceProvider"