phpvms/app/Http/Controllers/Api/FlightController.php

34 lines
775 B
PHP
Raw Normal View History

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