mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-08 12:29:26 +01:00
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Plugin;
|
|
|
|
use App\Facades\Plugins;
|
|
use App\Models\Plugin;
|
|
use Illuminate\Console\Command;
|
|
|
|
class UninstallPluginCommand extends Command
|
|
{
|
|
protected $signature = 'p:plugin:uninstall {id?} {--delete : Delete the plugin files}';
|
|
|
|
protected $description = 'Uninstalls a plugin';
|
|
|
|
public function handle(): void
|
|
{
|
|
$id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray());
|
|
|
|
$plugin = Plugin::find($id);
|
|
|
|
if (!$plugin) {
|
|
$this->error('Plugin does not exist!');
|
|
|
|
return;
|
|
}
|
|
|
|
if (!$plugin->isInstalled()) {
|
|
$this->error('Plugin is not installed!');
|
|
|
|
return;
|
|
}
|
|
|
|
$deleteFiles = $this->option('delete');
|
|
if ($this->input->isInteractive() && !$deleteFiles) {
|
|
$deleteFiles = $this->confirm('Do you also want to delete the plugin files?');
|
|
}
|
|
|
|
Plugins::uninstallPlugin($plugin, $deleteFiles);
|
|
|
|
$this->info('Plugin uninstalled' . ($deleteFiles ? ' and files deleted' : '') . '.');
|
|
}
|
|
}
|