Add /api/fleet to get subfleets and all the aircraft #120
This commit is contained in:
34
app/Http/Controllers/Api/FleetController.php
Normal file
34
app/Http/Controllers/Api/FleetController.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Repositories\AircraftRepository;
|
||||
use App\Repositories\SubfleetRepository;
|
||||
|
||||
use App\Http\Resources\Subfleet as SubfleetResource;
|
||||
|
||||
class FleetController extends RestController
|
||||
{
|
||||
protected $aircraftRepo, $subfleetRepo;
|
||||
|
||||
public function __construct(
|
||||
AircraftRepository $aircraftRepo,
|
||||
SubfleetRepository $airportRepo
|
||||
) {
|
||||
$this->aircraftRepo = $airportRepo;
|
||||
$this->subfleetRepo = $airportRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all the subfleets and the aircraft and any other associated data
|
||||
* Paginated
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$airports = $this->subfleetRepo
|
||||
->with(['aircraft', 'airline', 'fares', 'ranks'])
|
||||
->paginate(50);
|
||||
|
||||
return SubfleetResource::collection($airports);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user