/**
  * Get a list of the beers offered by a brewery
  *
  * @param $id
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function beers($id)
 {
     $brewery = Brewery::find($id);
     if (count($brewery) < 1) {
         return response(['status' => 'failed', 'message' => 'Brewery with id ' . $id . ' not found'], 404);
     }
     $brewery->load('beers');
     return response(['status' => 'ok', 'message' => 'List of beers for the brewery', 'brewery' => $brewery]);
 }
Beispiel #2
0
<?php

Route::get('/', function () {
    return 'API pronta para receber chamadas';
});
Route::get('cervejarias', ['middleware' => 'cors', function () {
    return \Response::json(\App\Brewery::with('beers', 'geocode')->take(100)->get(), 200);
}]);
Route::get('breweries', ['middleware' => 'cors', function () {
    return \Response::json(\App\Brewery::with('beers', 'geocode')->take(100)->get(), 200);
}]);
Route::get('cervejas', ['middleware' => 'cors', function () {
    return \Response::json(\App\Beer::with('brewery')->paginate(10), 200);
}]);
Route::get('beers', ['middleware' => 'cors', function () {
    return \Response::json(\App\Beer::with('brewery')->paginate(10), 200);
}]);