diff --git a/app/Http/Controllers/V2/Admin/PluginController.php b/app/Http/Controllers/V2/Admin/PluginController.php index da41477..a0ffbcf 100644 --- a/app/Http/Controllers/V2/Admin/PluginController.php +++ b/app/Http/Controllers/V2/Admin/PluginController.php @@ -106,6 +106,8 @@ class PluginController extends Controller 'config' => $pluginConfig, 'readme' => $readmeContent, 'need_upgrade' => $needUpgrade, + 'admin_menus' => $config['admin_menus'] ?? null, + 'admin_crud' => $config['admin_crud'] ?? null, ]; } } diff --git a/app/Services/Plugin/PluginManager.php b/app/Services/Plugin/PluginManager.php index 7859da0..21f126d 100644 --- a/app/Services/Plugin/PluginManager.php +++ b/app/Services/Plugin/PluginManager.php @@ -8,7 +8,6 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\Route; -use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; @@ -219,6 +218,20 @@ class PluginManager return $defaultValues; } + /** + * 获取 Migrator 实例并确保迁移仓库存在 + */ + protected function getMigrator(): \Illuminate\Database\Migrations\Migrator + { + $migrator = app('migrator'); + + if (!$migrator->repositoryExists()) { + $migrator->getRepository()->createRepository(); + } + + return $migrator; + } + /** * 运行插件数据库迁移 */ @@ -227,10 +240,8 @@ class PluginManager $migrationsPath = $this->getPluginPath($pluginCode) . '/database/migrations'; if (File::exists($migrationsPath)) { - Artisan::call('migrate', [ - '--path' => "plugins/" . Str::studly($pluginCode) . "/database/migrations", - '--force' => true - ]); + $migrator = $this->getMigrator(); + $migrator->run([$migrationsPath]); } } @@ -242,10 +253,8 @@ class PluginManager $migrationsPath = $this->getPluginPath($pluginCode) . '/database/migrations'; if (File::exists($migrationsPath)) { - Artisan::call('migrate:rollback', [ - '--path' => "plugins/" . Str::studly($pluginCode) . "/database/migrations", - '--force' => true - ]); + $migrator = $this->getMigrator(); + $migrator->rollback([$migrationsPath]); } }