/**
  * Shows the welcome view with a list with all plants in system
  * and a list with all recipes in system
  */
 public function showWelcome()
 {
     $plants = Plants::all();
     $recipes = Recipes::all();
     $data = array('plants' => $plants, 'recipes' => $recipes);
     return View::make('welcomeView')->with('data', $data);
 }
 public function addNewRecipeToDb()
 {
     // @todo add all otherIngredients to the recipe as well
     $newRecipe = new Recipes();
     $plantRecipe = new PlantRecipe();
     $recipeId = sizeof(Recipes::all()) + 1;
     $plants = Plants::all();
     $otherIngredients = Otheringredients::all();
     $plantsAddedToRecipeArray = array();
     $this->recipeSetup($newRecipe);
     foreach ($plants as $plant) {
         if (Input::get('plantId_' . $plant->id) === 'yes') {
             $plantsAddedToRecipeArray[] = $plant->id;
         }
     }
     $plantRecipe->savePlantRecipeConnectionToDb($recipeId, $plantsAddedToRecipeArray);
     $newRecipe->save();
     $data = array('plants' => $plants, 'otherIngredients' => $otherIngredients);
     return View::make('addRecipeView')->with('data', $data);
 }
Beispiel #3
0
<?php

header('Content-Type: text/html; charset=utf-8');
error_reporting(E_ALL);
ini_set('display_errors', 1);
// include the items class
include_once 'classes/RecipesClass.php';
// response
$response = array();
$encoded;
$recipes = new Recipes();
$allRecipes = $recipes->all();
if (isset($allRecipes)) {
    $response['data'] = $allRecipes;
}
// response
echo json_encode($response, JSON_PRETTY_PRINT);