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

59 lines
1.2 KiB
PHP
Raw Normal View History

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