Closed scramatte closed 2 years ago
You can't use nova-settings in the config files. Nova Settings values depend on a database and config files are created before the database connection is set up (which is also set up using config files, so it's a loop pretty much).
We wanted to use these settings in config, so the approach was to create a helper to safely check for the value, then use it in our service providers to set config values:
Helper:
use Illuminate\Support\Facades\Schema;
function safe_nova_get_setting($settingName, $fallbackValue) {
$return = $fallbackValue;
if(Schema::hasTable('nova_settings')) {
try {
$return = nova_get_setting($settingName, $fallbackValue);
} catch (Throwable $e) {}
}
return $return;
}
In AppServiceProvider@boot
:
config([
'app.timezone' => safe_nova_get_setting('APP_TIMEZONE', 'UTC'),
// ...
]);
This is working fine so far, but hasn't been thoroughly tested.
Hello,
I would like to use nova_get_setting into config/* files for notifications, mail and ldap settings I've got the following error
Call to a member function connection() on null
Thank you for the help