phpvms/app/Http/Controllers/Api/AirlineController.php
Nabeel S d68d8791bd
389 API Changes (#393)
* Update PHPUnit to 8

* Fix API endpoints closes #389

* Update pagination method in Repository contract to look at the page number closes #390

* Remove unused imports

* Fix tests in FlightTests

* Typecast page

* Don't register factories

* Remove Factory loading

* Remove unused imports
2019-09-13 11:21:40 -04:00

55 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Api;
use App\Contracts\Controller;
use App\Http\Resources\Airline as AirlineResource;
use App\Repositories\AirlineRepository;
use Illuminate\Http\Request;
class AirlineController extends Controller
{
private $airlineRepo;
/**
* AirlineController constructor.
*
* @param AirlineRepository $airlineRepo
*/
public function __construct(
AirlineRepository $airlineRepo
) {
$this->airlineRepo = $airlineRepo;
}
/**
* Return all the airlines, paginated
*
* @param Request $request
*
* @return mixed
*/
public function index(Request $request)
{
$airports = $this->airlineRepo
->whereOrder(['active' => true], 'name', 'asc')
->paginate();
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));
}
}