Add /api/flights to retrieve all flights paginated #120

This commit is contained in:
Nabeel Shahzad
2018-01-06 15:21:21 -06:00
parent 2de8d9ed64
commit 082c33ae59
4 changed files with 30 additions and 2 deletions

View File

@@ -18,6 +18,18 @@ class FlightController extends RestController
$this->flightRepo = $flightRepo;
}
/**
* Return all the flights, paginated
*/
public function index(Request $request)
{
$flights = $this->flightRepo
->orderBy('flight_number', 'asc')
->paginate(50);
return FlightResource::collection($flights);
}
public function get($id)
{
$flight = $this->flightRepo->find($id);