From d02bbe2ceab3225b6b91858c1b18572354a069e1 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Thu, 7 Aug 2025 10:00:36 +0200 Subject: [PATCH] remove need for static `get` and `make` methods --- app/Models/Plugin.php | 18 +++++++++--------- app/Services/Helpers/PluginService.php | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/Models/Plugin.php b/app/Models/Plugin.php index 49786dc55..55bf96400 100644 --- a/app/Models/Plugin.php +++ b/app/Models/Plugin.php @@ -320,10 +320,10 @@ class Plugin extends Model implements HasPluginSettings public function hasSettings(): bool { $class = $this->fullClass(); - if (class_exists($class) && method_exists($class, 'get')) { - $pluginObject = ($class)::get(); + if (class_exists($class)) { + $pluginObject = filament($this->id); - return method_exists($pluginObject, 'getSettingsForm') && method_exists($pluginObject, 'saveSettings'); + return $pluginObject instanceof HasPluginSettings; } return false; @@ -335,10 +335,10 @@ class Plugin extends Model implements HasPluginSettings public function getSettingsForm(): array { $class = $this->fullClass(); - if (class_exists($class) && method_exists($class, 'get')) { - $pluginObject = ($class)::get(); + if (class_exists($class)) { + $pluginObject = filament($this->id); - if (method_exists($pluginObject, 'getSettingsForm')) { + if ($pluginObject instanceof HasPluginSettings) { return $pluginObject->getSettingsForm(); } } @@ -352,10 +352,10 @@ class Plugin extends Model implements HasPluginSettings public function saveSettings(array $data): void { $class = $this->fullClass(); - if (class_exists($class) && method_exists($class, 'get')) { - $pluginObject = ($class)::get(); + if (class_exists($class)) { + $pluginObject = filament($this->id); - if (method_exists($pluginObject, 'saveSettings')) { + if ($pluginObject instanceof HasPluginSettings) { $pluginObject->saveSettings($data); } } diff --git a/app/Services/Helpers/PluginService.php b/app/Services/Helpers/PluginService.php index e05fb899e..c69a551f8 100644 --- a/app/Services/Helpers/PluginService.php +++ b/app/Services/Helpers/PluginService.php @@ -140,7 +140,7 @@ class PluginService throw new Exception('Class "' . $pluginClass . '" not found'); } - $panel->plugin($pluginClass::make()); + $panel->plugin(new $pluginClass()); $this->enablePlugin($plugin); } catch (Exception $exception) {