Example #1
0
 public function getIndex()
 {
     if (\Auth::check()) {
         $user = \Auth::user();
         $recipes = \P4\Recipe::where('user_id', '=', \Auth::id())->orderBy('id', 'DESC')->get();
         $data = array('user' => $user, 'recipes' => $recipes);
         return view('welcome.index')->with($data);
     } else {
         return view('welcome.guestIndex');
     }
 }
Example #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $recipes = ['Italian Ciabatta Burgers' => ['Beef', 'Sandwich'], 'Asian Noodle Salad' => ['Pasta', 'Sides', 'Salad'], 'Caesar Salad' => ['Appetizers', 'Salad', 'Sides'], 'Glazed Teriyaki Chicken' => ['Chicken'], 'Southwestern Chicken Sausage Chili' => ['Appetizers', 'Sides'], 'Coconut-Crusted Chicken Fingers' => ['Chicken'], 'Steak Au Poivre' => ['Beef', 'Sides']];
     foreach ($recipes as $title => $tags) {
         $recipe = \P4\Recipe::where('title', 'like', $title)->first();
         foreach ($tags as $tagName) {
             $tag = \P4\Tag::where('tag_name', 'like', $tagName)->first();
             $recipe->tags()->save($tag);
         }
     }
 }
Example #3
0
 /**
  * Responds to requests to GET /batches/create
  */
 public function getCreate($incomingRecipeID = null)
 {
     //get list of recipes currently in the database for selection by the user
     $recipes = \p4\Recipe::all();
     if ($incomingRecipeID != null) {
         $recipeLookup = \p4\Recipe::where('id', '=', $incomingRecipeID)->get();
         //return 'THIS IS THE INCOMING RECIPE: '.$recipeLookup;
         return view('batches.create')->with('recipes', $recipeLookup);
     } else {
         //return 'Form to create a new batch';
         return view('batches.create')->with('recipes', $recipes);
     }
 }
Example #4
0
 /**
  *responds to GET /recipes/likedbyme
  */
 public function getLikedByMe()
 {
     $user = \Auth::id();
     $likes = \P4\Like::where('user_id', '=', $user)->get();
     $recipeIds = [];
     foreach ($likes as $like) {
         $recipeIds[$like->recipe_id] = $like->recipe_id;
     }
     $recipes = \P4\Recipe::whereIn('id', $recipeIds)->get();
     return view('recipes.like')->with('recipes', $recipes);
 }
Example #5
0
 public function postEdit(Request $request)
 {
     $recipe = \p4\Recipe::find($request->id);
     if (Auth::id() == $recipe->user_id) {
         $recipe->recipe_name = $request->recipe_name;
         $recipe->honey_type = $request->honey_type;
         $recipe->yeast_type = $request->yeast_type;
         $recipe->difficulty = $request->difficulty;
         $recipe->recipe_text = $request->recipe_text;
         $recipe->save();
         return redirect('/recipes/show/' . $recipe->id);
     } else {
         \Session::flash('flash_message', 'The recipe' . $recipe->recipe_name . ' does not belong to you. You cannot edit it.');
     }
 }