2018-04-03 11:35:25 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Widgets;
|
|
|
|
|
2019-07-16 03:44:31 +08:00
|
|
|
use App\Contracts\Widget;
|
2019-08-09 02:52:34 +08:00
|
|
|
use App\Services\AirportService;
|
2018-04-03 11:35:25 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
{
|
2020-02-29 11:50:41 +08:00
|
|
|
/** @var \App\Services\AirportService $airportSvc */
|
2019-08-09 02:52:34 +08:00
|
|
|
$airportSvc = app(AirportService::class);
|
|
|
|
$metar = $airportSvc->getMetar($this->config['icao']);
|
2018-04-03 11:35:25 +08:00
|
|
|
|
|
|
|
return view('widgets.weather', [
|
|
|
|
'config' => $this->config,
|
|
|
|
'metar' => $metar,
|
|
|
|
'unit_alt' => setting('units.altitude'),
|
|
|
|
'unit_dist' => setting('units.distance'),
|
|
|
|
'unit_temp' => setting('units.temperature'),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|