2017-08-15 07:26:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
use App\Http\Controllers\AppBaseController;
|
2017-12-05 00:59:25 +08:00
|
|
|
use App\Models\Transformers\FlightTransformer;
|
|
|
|
use App\Repositories\FlightRepository;
|
2017-08-15 07:26:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
class FlightController extends AppBaseController
|
|
|
|
{
|
2017-12-05 00:59:25 +08:00
|
|
|
protected $flightRepo;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
FlightRepository $flightRepo
|
|
|
|
) {
|
|
|
|
$this->flightRepo = $flightRepo;
|
|
|
|
}
|
2017-08-15 12:36:49 +08:00
|
|
|
|
|
|
|
public function get($id)
|
|
|
|
{
|
2017-12-05 00:59:25 +08:00
|
|
|
$flight = $this->flightRepo->find($id);
|
2017-08-15 12:36:49 +08:00
|
|
|
return fractal($flight, new FlightTransformer())->respond();
|
|
|
|
}
|
|
|
|
|
2017-08-15 07:26:20 +08:00
|
|
|
public function search(Request $request)
|
|
|
|
{
|
2017-12-05 00:59:25 +08:00
|
|
|
$flights = $this->flightRepo->searchCriteria($request)->paginate();
|
2017-08-15 07:26:20 +08:00
|
|
|
return fractal($flights, new FlightTransformer())->respond();
|
|
|
|
}
|
|
|
|
}
|