1

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.php

return [
  'name' => load_multisite_env('APP_NAME')
];

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

// Helper Function

function 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/AppServiceProvider

public 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.

Syed Aqeel
  • 1,009
  • 2
  • 13
  • 36

0 Answers0