add artisan command to disable plugin

This commit is contained in:
Boy132 2025-11-06 23:55:54 +01:00
parent 598e3e1401
commit 92484fa94d

View File

@ -0,0 +1,38 @@
<?php
namespace App\Console\Commands\Plugin;
use App\Facades\Plugins;
use App\Models\Plugin;
use Illuminate\Console\Command;
class DisablePluginCommand extends Command
{
protected $signature = 'p:plugin:disable {id?}';
protected $description = 'Disables a plugin';
public function handle(): void
{
$id = $this->argument('id') ?? $this->choice('Plugin', Plugin::pluck('name', 'id')->toArray());
/** @var ?Plugin $plugin */
$plugin = Plugin::where('id', $id)->first();
if (!$plugin) {
$this->error('Plugin does not exist!');
return;
}
if (!$plugin->canDisable()) {
$this->error("Plugin can't be disabled!");
return;
}
Plugins::disablePlugin($plugin);
$this->info('Plugin disabled.');
}
}