Пример #1
0
 public static function addComponent($dishId, $recipeId, $quantity, $unitName)
 {
     if (Unit::exists($newUnit) && Recipe::exists($recipeId)) {
         $db = self::getInstance();
         if ($db->insert('DishRecipes', ['Dishes_id' => $dishId, 'Recipes_id' => $recipeId, 'quantity' => $quantity, 'unit' => $unitName])) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #2
0
 public function delete_recipe()
 {
     $flash_string = '';
     if (Session::exists('account')) {
         $flash_string = Session::flash('account');
     }
     $user = new User();
     if ($user->isLoggedIn()) {
         if (Recipe::exists(Input::get('recipe_id'))) {
             Recipe::deleteIngredient();
             Session::flash('account', 'Recipe deleted');
         } else {
             Session::flash('account', 'Recipe could not be deleted');
         }
         Redirect::to('account/recipes');
     } else {
         Session::flash('home', 'You have been logged out, please log back in');
         Redirect::to('home');
     }
 }
 function unstarRecipe($usr, $recipe_id)
 {
     $con1 = new SQLconnection();
     $user = new User($usr);
     $recipe = new Recipe($recipe_id);
     if ($recipe->exists()) {
         //$table="Starred";
         //$conditions=array();
         //$user_id=new stdClass();
         //$user_id->column="user_id";
         //$user_id->value=$user->id();
         //$user_id->compare="=";
         //$user_id->logical="and";
         //$recipe_id1=new stdClass();
         //$recipe_id1->column="recipe_id";
         //$recipe_id1->value=$recipe->id();
         //$recipe_id1->compare="=";
         //$recipe_id1->logical="";
         //$conditions=array($user_id,$recipe_id1);
         try {
             if (!($usr = (int) $usr)) {
                 return;
             }
             if (!($recipe_id = (int) $recipe_id)) {
                 return;
             }
             $con1->pdo_query(" delete from Starred where user_id  = {$usr} and recipe_id={$recipe_id};");
             //$con1->pdo_delete($table,$conditions);
         } catch (PDOException $Exception) {
             print_r($Exception);
             $res = $Exception;
             return $res;
         }
     }
     unset($this->recipes);
     $this->recipes = array();
     $this->loadRecipes($user->id());
 }
Пример #4
0
    }
    ?>
							 </tbody>
						  </table>
						  <?php 
} else {
    echo "<p>Sorry, you don't currently have any starred recipes, get started by starring recipes you like</p>";
}
?>
					</div>
				  </div>
				</div>
				<div class="col-xs-12 col-sm-12 col-md-8">
				  <div class="thumbnail">
				  <?php 
if ($recipe->exists()) {
    ?>
					<img id="recipe-photo" src="<?php 
    echo "images/recipes/" . $recipe->imageUrl();
    ?>
" title="<?php 
    echo $recipe->name();
    ?>
 photo" alt="<?php 
    echo $recipe->name();
    ?>
 photo">
				  <?php 
}
?>
	
Пример #5
0
 function _recipe_name_exists($recipe_name)
 {
     $recipe = new Recipe();
     $recipe->where('name', $recipe_name)->get();
     if ($recipe->exists()) {
         return false;
     }
     return true;
 }