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