phpvms/app/Http/Controllers/Api/AirlineController.php
Nabeel S 12848091a2
Laravel 9 Update (#1413)
Update to Laravel 9 and PHP 8+

Co-authored-by: B.Fatih KOZ <fatih.koz@gmail.com>
2022-03-14 11:45:18 -04:00

52 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 AirlineRepository $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)
{
$airlines = $this->airlineRepo->whereOrder(['active' => true], 'name')->paginate();
return AirlineResource::collection($airlines);
}
/**
* 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));
}
}