コード例 #1
0
 public function showRecipeDetail($recipeId)
 {
     $theRecipe = Recipes::find($recipeId);
     $plantRecipe = new PlantRecipe();
     $plantsForRecipe = $plantRecipe->findPlantsForRecipe($recipeId);
     $data = array('recipe' => $theRecipe, 'plants' => $plantsForRecipe);
     return View::make('recipeDetailView')->with('data', $data);
 }
コード例 #2
0
 /**
  * Finds all the plant associated with the given recipe
  * @param $recipeId
  * @return array
  */
 public function findPlantsForRecipe($recipeId)
 {
     $plants = PlantRecipe::where('recipe_id', '=', $recipeId)->get();
     $plantArray = array();
     foreach ($plants as $plant) {
         $plantArray[] = Plants::where('id', '=', $plant['plant_id'])->get()[0];
     }
     return $plantArray;
 }