byos_laravel/app/Console/Commands/FirmwareCheckCommand.php
Benjamin Nussbaum b4b6286172
Some checks are pending
tests / ci (push) Waiting to run
refactor: apply rector
2025-09-24 20:35:48 +02:00

38 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\FirmwarePollJob;
use App\Models\Firmware;
use Illuminate\Console\Command;
use function Laravel\Prompts\spin;
use function Laravel\Prompts\table;
class FirmwareCheckCommand extends Command
{
protected $signature = 'trmnl:firmware:check {--download : Download the latest firmware if available}';
protected $description = 'Checks for the latest firmware and downloads it if flag --download is passed.';
public function handle(): void
{
spin(
callback: fn () => FirmwarePollJob::dispatchSync(download: $this->option('download')),
message: 'Checking for latest firmware...'
);
$latestFirmware = Firmware::getLatest();
if ($latestFirmware instanceof Firmware) {
table(
rows: [
['Latest Version', $latestFirmware->version_tag],
['Download URL', $latestFirmware->url],
['Storage Location', $latestFirmware->storage_location],
]
);
} else {
$this->error('No firmware found.');
}
}
}