add artisan command to update plugin

This commit is contained in:
Boy132 2025-08-04 11:17:48 +02:00
parent a741be7226
commit be404a8332

View File

@ -0,0 +1,36 @@
<?php
namespace App\Console\Commands\Plugin;
use App\Facades\Plugins;
use App\Models\Plugin;
use Illuminate\Console\Command;
class UpdatePluginCommand extends Command
{
protected $signature = 'p:plugin:update {id}';
protected $description = 'Updates a plugin';
public function handle(): void
{
/** @var ?Plugin $plugin */
$plugin = Plugin::where('id', $this->argument('id'))->first();
if (!$plugin) {
$this->error('Plugin does not exist!');
return;
}
if (!$plugin->isUpdateAvailable()) {
$this->error("Plugin doesn't need updating!");
return;
}
Plugins::updatePlugin($plugin);
$this->info('Plugin updated.');
}
}