From 10137a602ab134637d56737a5caa930383ba85e1 Mon Sep 17 00:00:00 2001 From: Henry Whitaker Date: Sun, 13 Dec 2020 16:26:54 +0000 Subject: [PATCH] Load integrations config with db data --- app/Providers/IntegrationsServiceProvider.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/app/Providers/IntegrationsServiceProvider.php b/app/Providers/IntegrationsServiceProvider.php index e896ef13..3ec0d2ca 100644 --- a/app/Providers/IntegrationsServiceProvider.php +++ b/app/Providers/IntegrationsServiceProvider.php @@ -35,18 +35,30 @@ class IntegrationsServiceProvider extends ServiceProvider */ public function boot() { - if(File::exists(env('DB_DATABASE'))) { - if(Schema::hasTable('settings')) { + if (File::exists(env('DB_DATABASE'))) { + if (Schema::hasTable('settings')) { $setting = SettingsHelper::get('healthchecks_uuid'); - if($setting !== false) { + if ($setting !== false) { try { - App::bind('healthcheck', function() use ($setting) { + // Update config with DB values + config([ + 'integrations' => [ + 'healthchecks_enabled' => SettingsHelper::get('healthchecks_enabled')->value, + 'healthchecks_uuid' => SettingsHelper::get('healthchecks_uuid')->value, + 'healthchecks_uuid' => SettingsHelper::get('healthchecks_uuid')->value, + 'slack_webhook' => SettingsHelper::get('slack_webhook')->value, + 'telegram_bot_token' => SettingsHelper::get('telegram_bot_token')->value, + 'telegram_chat_id' => SettingsHelper::get('telegram_chat_id')->value, + ] + ]); + + App::bind('healthcheck', function () use ($setting) { return new Healthchecks($setting->value); }); - } catch(InvalidUuidStringException $e) { + } catch (InvalidUuidStringException $e) { Log::error('Invalid healthchecks UUID'); - } catch(Exception $e) { + } catch (Exception $e) { Log::error($e->getMessage()); } }