2018-01-07 05:13:33 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
use App\Repositories\AirlineRepository;
|
|
|
|
use App\Http\Resources\Airline as AirlineResource;
|
|
|
|
|
|
|
|
class AirlineController extends RestController
|
|
|
|
{
|
|
|
|
protected $airlineRepo;
|
|
|
|
|
|
|
|
public function __construct(AirlineRepository $airlineRepo) {
|
|
|
|
$this->airlineRepo = $airlineRepo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all the airlines, paginated
|
|
|
|
*/
|
|
|
|
public function index(Request $request)
|
|
|
|
{
|
|
|
|
$airports = $this->airlineRepo
|
2018-02-13 02:05:10 +08:00
|
|
|
->whereOrder(['active' => true], 'name', 'asc')
|
2018-01-07 05:13:33 +08:00
|
|
|
->paginate(50);
|
|
|
|
|
|
|
|
return AirlineResource::collection($airports);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Do a lookup, via vaCentral, for the airport information
|
|
|
|
* @param $id
|
|
|
|
* @return AirlineResource
|
|
|
|
*/
|
|
|
|
public function get($id)
|
|
|
|
{
|
|
|
|
$id = strtoupper($id);
|
|
|
|
return new AirlineResource($this->airlineRepo->find($id));
|
|
|
|
}
|
|
|
|
}
|