Skip to content

Commit b4ebf02

Browse files
authored
Add documentation for new closure support (#126)
1 parent 46b7f75 commit b4ebf02

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

resources/views/docs/desktop/1/the-basics/settings.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ To retrieve a setting, use the `get` method.
2727
$value = Settings::get('key');
2828
```
2929

30-
You may also provide a default value to return if the setting does not exist.
30+
You may also provide a default value to return if the setting does not exist. You can provide either a static default value, or a closure:
3131
```php
3232
$value = Settings::get('key', 'default');
3333
```
34-
If the setting does not exist, `default` will be returned.
34+
```php
35+
$value = Settings::get('key', function () {
36+
return 'default';
37+
});
38+
```
39+
If the setting does not exist, and no default value is provided, `null` will be returned.
3540

3641
### Forgetting a value
3742
If you want to remove a setting altogether, use the `forget` method.

0 commit comments

Comments
 (0)