phpvms/app/Http/Controllers/Api/FlightController.php
2017-12-04 10:59:25 -06:00

34 lines
775 B
PHP

<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use App\Http\Controllers\AppBaseController;
use App\Models\Transformers\FlightTransformer;
use App\Repositories\FlightRepository;
class FlightController extends AppBaseController
{
protected $flightRepo;
public function __construct(
FlightRepository $flightRepo
) {
$this->flightRepo = $flightRepo;
}
public function get($id)
{
$flight = $this->flightRepo->find($id);
return fractal($flight, new FlightTransformer())->respond();
}
public function search(Request $request)
{
$flights = $this->flightRepo->searchCriteria($request)->paginate();
return fractal($flights, new FlightTransformer())->respond();
}
}