byos_laravel/app/Console/Commands/ScreenGeneratorCommand.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

46 lines
1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\GenerateScreenJob;
use Illuminate\Console\Command;
use Throwable;
class ScreenGeneratorCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'trmnl:screen:generate {deviceId=1} {view=trmnl}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Generate a screen for a terminal device';
/**
* Execute the console command.
*/
public function handle(): int
{
$deviceId = $this->argument('deviceId');
$view = $this->argument('view');
try {
$markup = view($view)->render();
} catch (Throwable $e) {
$this->error('Failed to render view: '.$e->getMessage());
return 1;
}
GenerateScreenJob::dispatchSync($deviceId, null, $markup);
$this->info('Screen generation job finished.');
return 0;
}
}