Files
speedtest-tracker/app/Console/Commands/RunSpeedtest.php
T
Alex Justesen b29290913a Laravel 10.x Shift (#576)
Co-authored-by: Shift <shift@laravelshift.com>
2023-05-07 11:22:45 -04:00

43 lines
935 B
PHP

<?php
namespace App\Console\Commands;
use App\Jobs\ExecSpeedtest;
use Illuminate\Console\Command;
class RunSpeedtest extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:speedtest
{server? : Specify a server to run the test against}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Run a speedtest using Speedtest by Ookla';
/**
* Execute the console command.
*/
public function handle(): int
{
$speedtest = [];
if ($this->argument('server')) {
$speedtest = array_merge($speedtest, ['ookla_server_id' => $this->argument('server')]);
}
ExecSpeedtest::dispatch(speedtest: $speedtest);
$this->info('✅ added manual speedtest to the queue');
return 0;
}
}