Skip to content

Commit

Permalink
Update helpers.php
Browse files Browse the repository at this point in the history
  • Loading branch information
summerblue committed Dec 26, 2017
1 parent ca48d8e commit fb1eafb
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/helpers.php
@@ -1,14 +1,30 @@
<?php

function setting($key, $default = '', $setting_name = 'site')
if (!function_exists('setting'))
{
if ( ! config()->get($setting_name)) {
// Decode the settings to an associative array.
$site_settings = json_decode(file_get_contents(storage_path("/administrator_settings/$setting_name.json")), true);
// Add the site settings to the application configuration
config()->set($setting_name, $site_settings);
function setting($key, $default = '', $setting_name = 'site')
{
if ( ! config()->get($setting_name)) {
// Decode the settings to an associative array.
$site_settings = json_decode(file_get_contents(storage_path("/administrator_settings/$setting_name.json")), true);
// Add the site settings to the application configuration
config()->set($setting_name, $site_settings);
}

// Access a setting, supplying a default value
return config()->get($setting_name.'.'.$key, $default);
}
} else {
function admin_setting($key, $default = '', $setting_name = 'site')
{
if ( ! config()->get($setting_name)) {
// Decode the settings to an associative array.
$site_settings = json_decode(file_get_contents(storage_path("/administrator_settings/$setting_name.json")), true);
// Add the site settings to the application configuration
config()->set($setting_name, $site_settings);
}

// Access a setting, supplying a default value
return config()->get($setting_name.'.'.$key, $default);
// Access a setting, supplying a default value
return config()->get($setting_name.'.'.$key, $default);
}
}

0 comments on commit fb1eafb

Please sign in to comment.