mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 20:49:26 +01:00
39 lines
854 B
PHP
39 lines
854 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands\Plugin;
|
|
|
|
use App\Facades\Plugins;
|
|
use App\Models\Plugin;
|
|
use Illuminate\Console\Command;
|
|
|
|
class InstallPluginCommand extends Command
|
|
{
|
|
protected $signature = 'p:plugin:install {--id=}';
|
|
|
|
protected $description = 'Installs a plugin';
|
|
|
|
public function handle(): void
|
|
{
|
|
$id = $this->option('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->isInstalled()) {
|
|
$this->error('Plugin is already installed!');
|
|
|
|
return;
|
|
}
|
|
|
|
Plugins::installPlugin($plugin);
|
|
|
|
$this->info('Plugin installed and enabled.');
|
|
}
|
|
}
|