Initial commit
This commit is contained in:
35
app/Helpers/TimebankConfig.php
Normal file
35
app/Helpers/TimebankConfig.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('timebank_config')) {
|
||||
/**
|
||||
* Get platform-specific configuration value
|
||||
*
|
||||
* This function dynamically loads configuration from the file specified
|
||||
* in the TIMEBANK_CONFIG environment variable (defaults to 'timebank-default').
|
||||
*
|
||||
* @param string $key Configuration key in dot notation (e.g., 'profiles.user.limit_max')
|
||||
* @param mixed $default Default value if key is not found
|
||||
* @return mixed
|
||||
*
|
||||
* @example
|
||||
* // Get user profile limit_max from config/{TIMEBANK_CONFIG}.php
|
||||
* $limitMax = timebank_config('profiles.user.limit_max');
|
||||
*
|
||||
* // With a default value
|
||||
* $limitMax = timebank_config('profiles.user.limit_max', 6000);
|
||||
*/
|
||||
function timebank_config($key, $default = null)
|
||||
{
|
||||
static $configName = null;
|
||||
|
||||
// Cache the config name to avoid repeated env() calls
|
||||
if ($configName === null) {
|
||||
$configName = env('TIMEBANK_CONFIG', 'timebank-default');
|
||||
}
|
||||
|
||||
// Build the full config key
|
||||
$fullKey = $configName . '.' . $key;
|
||||
|
||||
return config($fullKey, $default);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user