laravel-rabbitmq/producer/app/Console/Commands/JobRun.php

42 lines
771 B
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\ScreenshotJob;
use Illuminate\Console\Command;
class JobRun extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'job:run {--count=1}';
/**
* The console command description.
*
* @var string
*/
protected $description = '';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$count = $this->option('count');
if (!is_numeric($count)) {
$count = 1;
}
$this->output->title('count: ' . $count);
for ($i = 1; $i <= $count; $i++) {
dispatch(new ScreenshotJob);
}
}
}