Skip to content

Commit

Permalink
Merge pull request #8 from mf16/master
Browse files Browse the repository at this point in the history
Update get call to include optional default
  • Loading branch information
akiyamaSM authored Mar 30, 2019
2 parents 0db86dc + 32f5ede commit a7e213c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ And then just you have to manipulate the settings.


```php

// Get the value of the API_GOOGLE key, null if it doesn't exist

use Inani\LaravelNovaConfiguration\Helpers\Configuration;

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

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

#### Updating the sidebar bar label
Expand Down
6 changes: 3 additions & 3 deletions src/Helpers/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class Configuration extends Model
* @param $key
* @return mixed
*/
public static function get($key)
public static function get($key, $default = null)
{
$line = self::getElementByKey($key);

if(is_null($line)){
return null;
return $default;
}

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

return true;
}
}
}

0 comments on commit a7e213c

Please sign in to comment.