From d37f443871d0cb8d33a160573953f41473a344bf Mon Sep 17 00:00:00 2001 From: Travis Elkins Date: Fri, 26 Apr 2024 17:32:42 +0200 Subject: [PATCH] Removed Model::getConnectionName() override and moved fallback to each call. --- src/Managers/TableSettingsManager.php | 2 +- src/Traits/HasSettingsField.php | 10 +--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/Managers/TableSettingsManager.php b/src/Managers/TableSettingsManager.php index 74ca1a6..a036f41 100644 --- a/src/Managers/TableSettingsManager.php +++ b/src/Managers/TableSettingsManager.php @@ -30,7 +30,7 @@ public function apply(array $settings = []): SettingsManagerContract } else { if (!$modelSettings) { $modelSettings = new ModelSettings(); - $modelSettings->setConnection($this->model->getConnectionName()); + $modelSettings->setConnection($this->model->getConnectionName() ?? config('database.default')); $modelSettings->model()->associate($this->model); } $modelSettings->settings = $settings; diff --git a/src/Traits/HasSettingsField.php b/src/Traits/HasSettingsField.php index 503865e..882b9e5 100644 --- a/src/Traits/HasSettingsField.php +++ b/src/Traits/HasSettingsField.php @@ -75,14 +75,6 @@ public function getSettingsFieldName(): string return $this->settingsFieldName ?? config('model_settings.settings_field_name'); } - /** - * @return string - */ - public function getConnectionName(): string - { - return $this->connection ?? config('database.default'); - } - /** * @return bool */ @@ -109,7 +101,7 @@ private function hasSettingsField() config('model_settings.settings_table_cache_prefix') . '::has_field', now()->addDays(1), function () { - return Schema::connection($this->getConnectionName()) + return Schema::connection($this->getConnectionName() ?? config('database.default')) ->hasColumn( $this->getTable(), $this->getSettingsFieldName()