Commit f61f545a authored by King Alex's avatar King Alex

Ajout d une recette

parent 878ae6ba
<?php
<?php
class RecipesTableSeeder extends Seeder {
......@@ -20,6 +17,18 @@ public function run()
$recipe2->description = "La longue description, c'est ici qu'il faut dire de melanger les ingredients";
$recipe2->save();
$recipe3 = new Recipe;
$recipe3->title = "Muffins au chocolat";
$recipe3->introduction = "Une recette a suivre pour les plus gourmands";
$recipe3->description = "
Étape 1 :\n
Faire fondre le chocolat avec le beurre au micro-ondes 2 min puis ajouter le sucre et les oeufs un par un. Battre avec un fouet, puis verser la farine et la levure.\n
Étape 2 :\n
Verser la préparation dans des petits moules siliconés.\n
Étape 3 :\n
Préchauffer le four 220°C pendant 10 min le temps de préparer puis faire cuire 10 min.";
$recipe3->save();
// Create Ingredients
$ingredient_chocolat = new Ingredient;
$ingredient_caramel = new Ingredient;
......@@ -40,6 +49,31 @@ public function run()
$ingredient_oeufs->save();
$ingredient_lait->save();
$ingredienta = new Ingredient;
$ingredienta->name = '2 œufs';
$ingredienta->save();
$ingredientb = new Ingredient;
$ingredientb->name = '100g de sucre';
$ingredientb->save();
$ingredientc = new Ingredient;
$ingredientc->name = '100g de chocolat noir';
$ingredientc->save();
$ingredientd = new Ingredient;
$ingredientd->name = '100g de beurre salé fondu';
$ingredientd->save();
$ingrediente = new Ingredient;
$ingrediente->name = '60g de farine';
$ingrediente->save();
$ingredientf = new Ingredient;
$ingredientf->name = '1 c à c de levure';
$ingredientf->save();
// Create images
$image1 = new Image;
$image1->path = base_path() . '/public/custom/img/uploads/'.'test1.jpg';
......@@ -53,6 +87,12 @@ public function run()
$image2->alt = 'test image 2';
$image2->save();
$image3 = new Image;
$image3->path = base_path() . '/public/custom/img/uploads/'.'test3.jpg';
$image3->name ='test3.jpg';
$image3->alt = 'test image 3';
$image3->save();
// Get categories
$cat_desserts = Category::where('name','dessert')->first();
$cat_main = Category::where('name','main')->first();
......@@ -60,24 +100,42 @@ public function run()
// Tests:
$recipe1 = Recipe::where('id',1)->first();
$recipe2 = Recipe::where('id',2)->first();
$recipe3 = Recipe::where('id',3)->first();
$testSubjectA = User::where('username', 'TestSubjectA')->first();
$testSubjectB = User::where('username', 'TestSubjectB')->first();
$recipe1->users()->attach($testSubjectA->id);
$recipe2->users()->attach($testSubjectB->id);
$recipe3->users()->attach($testSubjectB->id);
$recipe1->ingredients()->attach(array(
$ingredient_chocolat->id,
$ingredient_fraises->id
));
$recipe2->ingredients()->attach(array(
$ingredient_farine->id,
$ingredient_lait->id,
$ingredient_oeufs->id,
$ingredient_caramel->id
));
$recipe1->ingredients()->attach($ingredient_chocolat->id);
$recipe1->ingredients()->attach($ingredient_fraises->id);
$recipe2->ingredients()->attach($ingredient_farine->id);
$recipe2->ingredients()->attach($ingredient_lait->id);
$recipe2->ingredients()->attach($ingredient_oeufs->id);
$recipe2->ingredients()->attach($ingredient_caramel->id);
$recipe3->ingredients()->attach(array(
$ingredienta->id,
$ingredientb->id,
$ingredientc->id,
$ingredientd->id,
$ingrediente->id,
$ingredientf->id
));
$recipe1->categories()->attach($cat_desserts->id);
$recipe2->categories()->attach($cat_main->id);
$recipe3->categories()->attach($cat_main->id);
$recipe1->images()->attach($image1->id);
$recipe2->images()->attach($image2->id);
$recipe3->images()->attach($image3->id);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment