laravel-performance/app/Console/Commands/MassInsertCommand.php

61 lines
1018 B
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\MassInsert;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Bus;
class MassInsertCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:mass-insert
{--count=100: number of rows inserted}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'mass insert';
/**
* Execute the console command.
*/
public function handle(): void
{
$count = (int)$this->option('count');
Bus::chain([
(new MassInsert\MassInsert1Job($count)),
(new MassInsert\MassInsert2Job($count)),
(new MassInsert\MassInsert3Job($count)),
(new MassInsert\MassInsert4Job($count)),
(new MassInsert\MassInsert5Job($count)),
(new MassInsert\MassInsert6Job($count)),
])->dispatch();
}
}