/**
  * Get a list of all of the beers in the database
  *
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function index()
 {
     $usersBeers = $this->user->history()->pluck('beer_id');
     $beers = Beer::with('brewery', 'style')->whereNotIn('id', $usersBeers)->get();
     return response(['status' => 'ok', 'message' => 'Index of all the beer data stored in the database', 'copyright' => 'All information aggregated is information obtained from the brewer\'s website', 'beers' => $beers]);
 }
Beispiel #2
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
use App\User;
use App\Beer;
Route::get('/', function () {
    return view('welcome');
});
Route::get('/api/v1/beers', function () {
    header("Access-Control-Allow-Origin: *");
    return Beer::with('categories.ratings')->get();
});
Route::get('/api/v1/crisp', function () {
});
Route::get('/api/v1/search/{parameter}', function ($parameter) {
    header("Access-Control-Allow-Origin: *");
    if (!$parameter) {
        return [];
    }
    return Beer::where('name', 'LIKE', '%' . $parameter . '%')->get();
});
Route::get('/api/v1/beer/{id}', function ($id) {
    return Beer::find($id)->with('categories')->first();
});
Route::resource('api/v1/beer', 'BeerController');
Route::any('{all}', function ($uri) {
Beispiel #3
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);
}]);
 public function getEagerLoading()
 {
     return Beer::with('categories.ratings')->get();
 }
Beispiel #5
0
 public function getRecipe($id = null)
 {
     $beer = \App\Beer::with('recipe')->where('id', $id)->first();
     $ingredients = \App\Ingredient::get();
     $hidden = "";
     if ($beer->user_id == Auth::id()) {
         $hidden = "show";
     } else {
         $hidden = "hidden";
     }
     return view('beer.recipe')->with(['beer' => $beer, 'ingredients' => $ingredients])->with('hidden', $hidden);
 }