/** * Show the application dashboard. * * @return Response */ public function index() { $getrecipeid = Recipe::all()->random(1); //Signature Base String //<HTTP Method>&<Request URL>&<Normalized Parameters> $base = rawurlencode("GET") . "&"; $base .= "http%3A%2F%2Fplatform.fatsecret.com%2Frest%2Fserver.api&"; //sort params by abc....necessary to build a correct unique signature $params = "format=json&"; $params .= "method=recipe.get&"; $params .= "oauth_consumer_key=c1f69a4b6440454296fd1061870343a3&"; // ur consumer key $params .= "oauth_nonce=123&"; $params .= "oauth_signature_method=HMAC-SHA1&"; $params .= "oauth_timestamp=" . time() . "&"; $params .= "oauth_version=1.0&"; // $params .= "recipe_id=46784"; $params .= "recipe_id=" . $getrecipeid->recipe_id; $params2 = rawurlencode($params); $base .= $params2; //encrypt it! $sig = base64_encode(hash_hmac('sha1', $base, "8b7c290389fb484ea628384704941110&", true)); // replace xxx with Consumer Secret //now get the search results and write them down $url = "http://platform.fatsecret.com/rest/server.api?" . $params . "&oauth_signature=" . rawurlencode($sig); $food_feed = file_get_contents($url); $recipes = json_decode($food_feed); // echo '<pre>'; // print_r($recipes); // echo '</pre>'; return view('welcome')->with('recipes', $recipes); }
public function getHome() { $dates = []; $recipes = Recipe::all(); for ($i = 0; $i < 7; $i++) { array_push($dates, Carbon::now()->startOfWeek()->addDays($i)); } $datas = Day::whereBetween('date', array($dates[0], end($dates)))->get(); foreach ($dates as $key => $date) { if ($datas->whereLoose('date', $date)->first() != '') { $day = $datas->whereLoose('date', $date)->first(); } else { $day = Day::create(['date' => $date]); } $dates[$key] = $day; } $ingredients_list = collect(); foreach ($dates as $day) { foreach ($day->recipes as $recipe) { foreach ($recipe->ingredients as $ingredient) { if ($ingredients_list->where('id', $ingredient->id)->first() && $ingredients_list->where('id', $ingredient->id)->first()->pivot->unit == $ingredient->pivot->unit) { $ingredients_list->where('id', $ingredient->id)->first()->total += $ingredient->pivot->quantity; } else { $ingredients_list->push($ingredient); $ingredients_list->where('id', $ingredient->id)->first()->total = $ingredient->pivot->quantity; } } } } $supply = Auth::user()->ingredients; return view('page.home')->with(['days' => $dates, 'ingredients_list' => $ingredients_list, 'supply' => $supply]); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index($tag_id = null) { if ($tag_id) { $recipes = Recipe::whereHas('tags', function ($query) use($tag_id) { $query->where('id', $tag_id); })->get(); } else { $recipes = Recipe::all(); } $tags = Tag::where('for', 'recipe')->get(); $tag = Tag::find($tag_id); return view('recipes.index')->with(['recipes' => $recipes, 'tags' => $tags, 'the_tag' => $tag]); }
public function showAll() { $recipes = \App\Recipe::all(); $users = \App\User::all(); return view('show', ['users' => $users, 'recipes' => $recipes]); }
public function generate() { $dates = []; $recipes = Recipe::all(); for ($i = 0; $i < 7; $i++) { array_push($dates, Carbon::now()->startOfWeek()->addDays($i)); } $datas = Day::whereBetween('date', array($dates[0], end($dates)))->get(); foreach ($dates as $date) { if ($datas->whereLoose('date', $date)->first() != '') { $day = $datas->whereLoose('date', $date)->first(); $day->recipes()->detach(); $day->recipes()->attach($recipes->random()->id); } else { $day = Day::create(['date' => $date]); $day->recipes()->attach($recipes->random()->id); } } return redirect('/'); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $recipes = Recipe::all(); return view('recipes.index', compact('recipes')); }
/** * Display a listing of the resource in JSON. * * @return Response */ public function getRecipes() { $recipes = Recipe::all(); return $recipes; }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $recipes = \App\Recipe::all(); return \View::make('recipes.index')->with('recipes', $recipes); }