qcod/laravel-settings

Use inside config file

m7vm7v opened this issue · 7 comments

Is there a way of getting saved value inside the config file?

For example, if I have -
'name' => env('APP_NAME', 'Laravel'),

to become -
'name' => settings()->get('app_name', 'Laravel'),

As for now in L9 I get Target [QCod\Settings\Setting\SettingStorage] is not instantiable.

Since config are loaded very early I don't you can do it.

I do agree. I thought so. Tried to load the service provider early but the DB at this point isn't. Any workaround?

Do this in AppServiceProvider boot method

I have tried with
$this->app->bind( 'QCod\Settings\Setting\SettingStorage', 'QCod\Settings\Setting\SettingEloquentStorage' );
But still the same error appears

Something like this

config()->set('app.name', settings()->get('app_name', 'Laravel');

Thanks a lot for your help. Unfortunately, this does not seem to work as intended.

To add a context with a real-life case scenario.
I have a setting called "open_registration" which I'd like to use for fortify's feature.
In my config/fortify.php I'd like to have something like this -

if (settings()->get('open_registration', false)) {
    $features[] = Features::registration();
}

I have tried with the AppServiceProvider but at the time the config is cached it does not look like we are able to set it correctly.