mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 16:19:35 +01:00
add artisan command to disable plugin
This commit is contained in:
parent
598e3e1401
commit
92484fa94d
38
app/Console/Commands/Plugin/DisablePluginCommand.php
Normal file
38
app/Console/Commands/Plugin/DisablePluginCommand.php
Normal 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.');
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user