Skip to content

Commit a7e213c

Browse files
authored
Merge pull request #8 from mf16/master
Update get call to include optional default
2 parents 0db86dc + 32f5ede commit a7e213c

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ And then just you have to manipulate the settings.
5454

5555

5656
```php
57-
58-
// Get the value of the API_GOOGLE key, null if it doesn't exist
59-
6057
use Inani\LaravelNovaConfiguration\Helpers\Configuration;
6158

59+
// Get the value of the API_GOOGLE key, null if it doesn't exist
6260
$value = Configuration::get('API_GOOGLE');
6361

62+
// Get the value of the FOO key, 'BAR' if it doesn't exist
63+
$value = Configuration::get('FOO', 'BAR);
6464
```
6565

6666
#### Updating the sidebar bar label

src/Helpers/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ class Configuration extends Model
1515
* @param $key
1616
* @return mixed
1717
*/
18-
public static function get($key)
18+
public static function get($key, $default = null)
1919
{
2020
$line = self::getElementByKey($key);
2121

2222
if(is_null($line)){
23-
return null;
23+
return $default;
2424
}
2525

2626
return $line->value;
@@ -80,4 +80,4 @@ public static function setById($id, $key, $value)
8080

8181
return true;
8282
}
83-
}
83+
}

0 commit comments

Comments
 (0)