Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5054

Laravel - Cannot get updated config value when using helper function

$
0
0

I'm trying to get the config value when assigning the value to config via a helper function. For better understanding, let me give you an example:

Here is my config/app.php file:

// config/app.phpreturn ['name' => load_multisite_env('APP_NAME')];

and the helper function used in config/app.php is:

// Helper Functionfunction load_multisite_env($key) {  return env(    config('active.site') . $key,     env($key, null)  );}

And the value of config('active.site') will be set from AppServiceProvider as:

// app/Providers/AppServiceProviderpublic function boot() {  config(['active.site' => request()->get('active_site') ]);}

While if I try the helper function from the controller then it returns the correct value, but when I try to access the value through the config, it doesn't work.

As it looks like that the config value gets loaded before I set the active.set from the service provider.

Question is: How I can get the updated values of env in the config file after the app has been loaded?

Any help will be appreciated.

Thanks.


Viewing all articles
Browse latest Browse all 5054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>