You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -190,7 +192,8 @@ Now, you will have to add this settings class to the `settings.php` config file
190
192
191
193
```php
192
194
/*
193
-
* You can register all the settings classes here.
195
+
* Each settings class used in your application must be registered, you can
196
+
* put them (manually) here.
194
197
*/
195
198
'settings' => [
196
199
GeneralSettings::class
@@ -316,7 +319,7 @@ class CreateGeneralSettings extends SettingsMigration
316
319
}
317
320
```
318
321
319
-
We haven't added a `down` method, but this can be added if required. In the `up` method, you can change the settings data in a repository when migrating. There are a few default operations supported:
322
+
We haven't added a `down` method, but this can be added if disered. In the `up` method, you can change the settings data in a repository when migrating. There are a few default operations supported:
320
323
321
324
#### Adding a property
322
325
@@ -703,6 +706,30 @@ DateSettings::fake([
703
706
704
707
Now, when the `DateSettings` settings class is injected somewhere in your application, the `birth_date` property will be `DateTime('16-05-1994')`.
705
708
709
+
### Caching settings
710
+
711
+
It takes a small amount of time to load a settings class from a repository. When you've got many settings classes, these added small amounts of time can grow quickly out of hand. The package has built-in support for caching stored settings using the Laravel cache.
712
+
713
+
You should first enable the cache within the `settings.php` config file:
We suggest you enable caching in production by adding `SETTINGS_CACHE_ENABLED=true` to your `.env` file. It is also possible to define a store for the cache, which should be one of the stores you defined in the `cache.php` config file. If no store were defined, the default cache store would be taken. To avoid conflicts within the cache, you can also define a prefix that will be added to each cache entry.
724
+
725
+
That's it. The package is now smart enough to cache the settings the first time they're loaded. Whenever the settings are edited, the package will refresh the settings.
726
+
727
+
You can always clear the cached settings with the following command:
728
+
729
+
```bash
730
+
php artisan settings:clear-cache
731
+
```
732
+
706
733
### Auto discovering settings classes
707
734
708
735
Each settings class you create should be added to the `settings` array within the `settings.php` config file. When you've got a lot of settings, this can be quickly forgotten.
@@ -967,6 +994,15 @@ It is required to return raw values again in the `getPropertiesInGroup` and `get
967
994
968
995
Each repository's constructor will receive a `$config` array that the user-defined for the repository within the application `settings.php` config file. It is possible to add other dependencies to the constructor. They will be injected when the repository is created.
969
996
997
+
### Events
998
+
999
+
The package will emit a series of events when loading/saving settings classes:
1000
+
1001
+
-`LoadingSettings` whenever settings are loaded from the repository but not yet inserted in the settings class
1002
+
-`LoadedSettings` after settings are loaded into the settings class
1003
+
-`SavingSettings` whenever settings are saved to the repository but are not yet cast or encrypted
1004
+
-`SavedSettings` after settings are stored within the repository
0 commit comments