getFilenameWithoutExtension(); if (in_array($filename, ['ApiPluginInterface', 'LoggablePlugin', 'PluginLoader'])) { continue; } $class = 'App\Api\Plugins\\' . $filename; if (class_exists($class) && in_array(ApiPluginInterface::class, class_implements($class))) { try { // Check if there's an ApiProvider for this plugin $apiProvider = ApiProvider::where('plugin', $filename)->first(); $hasApiProvider = $apiProvider !== null; // Get plugin information without instantiating the class // This avoids issues with plugins requiring ApiProvider in constructor $reflection = new ReflectionClass($class); $instance = $reflection->newInstanceWithoutConstructor(); $plugins[] = new self([ 'id' => $instance->getIdentifier(), 'name' => $instance->getName(), 'identifier' => $instance->getIdentifier(), 'enabled' => $hasApiProvider && $apiProvider && $apiProvider->enabled, 'file_path' => $file->getPathname(), 'has_api_provider' => $hasApiProvider, 'configured' => $hasApiProvider ]); } catch (Exception $e) { // Log error or handle as needed } } } } return new \Illuminate\Database\Eloquent\Collection($plugins); } }