Ejemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @param Request $request
  * @return $this
  */
 public function index(Request $request)
 {
     $recipes = new Recipe();
     if ($request->exists('ingredient')) {
         foreach ($request->get('ingredient') as $ingredientId) {
             $recipes = $recipes->leftJoin('recipe_ingredients AS ri' . $ingredientId, '.recipes.id', '=', 'ri' . $ingredientId . '.recipe_id');
             $recipes = $recipes->where('ri' . $ingredientId . '.ingredient_id', '=', $ingredientId);
         }
     }
     $recipes = $recipes->groupBy('recipes.id')->orderBy('created_at', 'DESC')->get();
     $ingredients = Ingredient::orderBy('name')->get();
     return view('recipes.index')->with(compact('recipes', 'ingredients'));
 }
Ejemplo n.º 2
0
 public function getTest()
 {
     $ingredients = \App\Ingredient::orderBy('name')->get();
     return view('test')->with('ingredients', $ingredients);
 }
Ejemplo n.º 3
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $ingredient = Auth::user()->ingredients->find($id);
     $ingredients = Ingredient::orderBy('name')->get();
     return view('supplies.edit')->with(['the_ingredient' => $ingredient, 'ingredients' => $ingredients]);
 }