phpvms/app/Widgets/LiveMap.php
Arthur Parienté 992b6d343a
[8.x] feature: upgrade to Laravel 13 (#2204)
* upgrade to laravel 13

* phpstan

* rollback to symfony 7.4

* fix: ModuleService merge

* refactor: new rector rules
2026-05-06 11:27:21 -05:00

44 lines
1.1 KiB
PHP

<?php
namespace App\Widgets;
use App\Contracts\Widget;
use App\Models\Pirep;
use App\Services\GeoService;
use Illuminate\Contracts\View\Factory;
use Illuminate\View\View;
/**
* Show the live map in a view
*/
class LiveMap extends Widget
{
protected $config = [
'height' => '800px',
'width' => '100%',
'table' => true,
];
/**
* @return Factory|View
*/
public function run(): Factory|\Illuminate\Contracts\View\View
{
$geoSvc = app(GeoService::class);
$pireps = Pirep::activeFlights(setting('acars.live_time', 0))->get();
$positions = $geoSvc->getFeatureForLiveFlights($pireps);
$center_coords = setting('acars.center_coords', '0,0');
$center_coords = array_map(fn ($c): float => (float) trim($c), explode(',', $center_coords));
return view('widgets.live_map', [
'config' => $this->config,
'pireps' => $pireps,
'positions' => $positions,
'center' => $center_coords,
'zoom' => setting('acars.default_zoom', 5),
]);
}
}