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

47 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace App\Http\Controllers\Api;
use App\Interfaces\Controller;
use App\Repositories\AcarsRepository;
2018-02-21 12:33:09 +08:00
use App\Services\GeoService;
use Illuminate\Http\Request;
/**
* Class AcarsController
* @package App\Http\Controllers\Api
*/
class AcarsController extends Controller
{
private $acarsRepo,
$geoSvc;
2018-02-21 12:33:09 +08:00
/**
* AcarsController constructor.
* @param GeoService $geoSvc
2018-02-21 12:33:09 +08:00
* @param AcarsRepository $acarsRepo
*/
public function __construct(
GeoService $geoSvc,
AcarsRepository $acarsRepo
) {
$this->geoSvc = $geoSvc;
$this->acarsRepo = $acarsRepo;
}
/**
* 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'
]);
}
}