phpvms/app/Widgets/Weather.php
Nabeel S ea9ee985e8
METAR parsing infinite loop bugfix #599 (#600)
METAR parsing infinite loop bugfix #599
2020-02-28 22:50:41 -05:00

35 lines
820 B
PHP

<?php
namespace App\Widgets;
use App\Contracts\Widget;
use App\Services\AirportService;
/**
* This is a widget for the 3rd party CheckWX service
*/
class Weather extends Widget
{
protected $config = [
'icao' => null,
];
/**
* Attempt to get the data from the CheckWX API
*/
public function run()
{
/** @var \App\Services\AirportService $airportSvc */
$airportSvc = app(AirportService::class);
$metar = $airportSvc->getMetar($this->config['icao']);
return view('widgets.weather', [
'config' => $this->config,
'metar' => $metar,
'unit_alt' => setting('units.altitude'),
'unit_dist' => setting('units.distance'),
'unit_temp' => setting('units.temperature'),
]);
}
}