phpvms/app/Http/Controllers/Api/AcarsController.php

46 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\Api;
use App\Repositories\AcarsRepository;
use App\Repositories\PirepRepository;
2018-02-21 12:33:09 +08:00
use App\Services\GeoService;
use Illuminate\Http\Request;
class AcarsController extends RestController
{
protected $acarsRepo, $geoSvc, $pirepRepo;
2018-02-21 12:33:09 +08:00
/**
* AcarsController constructor.
* @param GeoService $geoSvc
* @param AcarsRepository $acarsRepo
* @param PirepRepository $pirepRepo
*/
public function __construct(
GeoService $geoSvc,
AcarsRepository $acarsRepo,
PirepRepository $pirepRepo
) {
$this->geoSvc = $geoSvc;
$this->acarsRepo = $acarsRepo;
$this->pirepRepo = $pirepRepo;
}
/**
* Return all of the flights (as points) in GeoJSON format
2018-02-21 12:33:09 +08:00
* @param Request $request
* @return mixed
*/
public function index(Request $request)
{
$pireps = $this->acarsRepo->getPositions();
$positions = $this->geoSvc->getFeatureForLiveFlights($pireps);
return response(json_encode($positions), 200, [
'Content-type' => 'application/json'
]);
}
}