/
helpers.php
42 lines (38 loc) · 1.51 KB
/
helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
if (!function_exists('setting'))
{
function setting($key, $default = '', $setting_name = 'site')
{
if ( ! config()->get($setting_name)) {
// Decode the settings to an associative array.
$file_path = storage_path("/administrator_settings/$setting_name.json");
if (file_exists($file_path)) {
$site_settings = json_decode(file_get_contents($file_path), true);
} else {
$site_settings = [];
}
// 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);
}
}
if (!function_exists('admin_setting')) {
function admin_setting($key, $default = '', $setting_name = 'site')
{
if ( ! config()->get($setting_name)) {
// Decode the settings to an associative array.
$file_path = storage_path("/administrator_settings/$setting_name.json");
if (file_exists($file_path)) {
$site_settings = json_decode(file_get_contents($file_path), true);
} else {
$site_settings = [];
}
// 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);
}
}