mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2026-01-03 11:34:51 +01:00
Added base app
Has basic login UI, has methods to run speedtests
This commit is contained in:
49
app/Console/Commands/SpeedtestCommand.php
Normal file
49
app/Console/Commands/SpeedtestCommand.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class SpeedtestCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'speedtest:run';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Performs a new speedtest';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$this->info('Running speedtest, this might take a while...');
|
||||
|
||||
$results = SpeedtestHelper::runSpeedtest();
|
||||
|
||||
$this->info('Ping: ' . $results->ping . ' ms');
|
||||
$this->info('Download: ' . $results->download . ' Mbit/s');
|
||||
$this->info('Upload: ' . $results->upload . ' Mbit/s');
|
||||
}
|
||||
}
|
||||
61
app/Console/Commands/SpeedtestLatestCommand.php
Normal file
61
app/Console/Commands/SpeedtestLatestCommand.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Helpers\SpeedtestHelper;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
|
||||
class SpeedtestLatestCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'speedtest:latest';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Returns the latest speedtest result';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$latest = SpeedtestHelper::latest();
|
||||
|
||||
if($latest) {
|
||||
$this->info('Last speedtest run at: ' . $latest->created_at);
|
||||
$this->info('Ping: ' . $latest->ping . ' ms');
|
||||
$this->info('Download: ' . $latest->download . ' Mbit/s');
|
||||
$this->info('Upload: ' . $latest->upload . ' Mbit/s');
|
||||
} else {
|
||||
$this->info('No speedtests have been run yet.');
|
||||
|
||||
$this->info('Running speedtest, this might take a while...');
|
||||
|
||||
$results = SpeedtestHelper::runSpeedtest();
|
||||
|
||||
$this->info('Ping: ' . $results->ping . ' ms');
|
||||
$this->info('Download: ' . $results->download . ' Mbit/s');
|
||||
$this->info('Upload: ' . $results->upload . ' Mbit/s');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user