-
Notifications
You must be signed in to change notification settings - Fork 133
/
FlightController.php
43 lines (34 loc) · 1006 Bytes
/
FlightController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace App\Http\Controllers\Api;
use Log;
use Illuminate\Http\Request;
use App\Http\Controllers\AppBaseController;
use App\Repositories\FlightRepository;
use App\Http\Resources\Flight as FlightResource;
use Prettus\Repository\Exceptions\RepositoryException;
class FlightController extends AppBaseController
{
protected $flightRepo;
public function __construct(FlightRepository $flightRepo) {
$this->flightRepo = $flightRepo;
}
public function get($id)
{
$flight = $this->flightRepo->find($id);
FlightResource::withoutWrapping();
return new FlightResource($flight);
}
/**
* @param Request $request
* @return mixed
*/
public function search(Request $request)
{
try {
$flights = $this->flightRepo->searchCriteria($request)->paginate();
} catch (RepositoryException $e) {
return response($e, 503);
}
return FlightResource::collection($flights);
}
}