Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $data = ['Happy', 'Angry', 'Sad', 'Easy', 'Busy', 'Dizzy', 'Crazy', 'Messy', 'Noisy', 'Grumpy', 'Funny', 'Jolly'];
     foreach ($data as $tagName) {
         $tag = new \P4\Tag();
         $tag->name = $tagName;
         $tag->save();
     }
 }
Ejemplo n.º 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $tagList = ['Appetizers', 'Baking', 'Beef', 'Breakfast', 'Chicken', 'Desserts', 'Drinks', 'Fish', 'Pasta', 'Pizza', 'Pork', 'Salad', 'Sides', 'Sandwich'];
     foreach ($tagList as $tagName) {
         $tag = new \P4\Tag();
         $tag->tag_name = $tagName;
         $tag->save();
     }
 }
Ejemplo n.º 3
0
 /**
  * Responds to requests to GET /photos/edit/{$id}
  */
 public function getEdit($id = null)
 {
     # Get this photo and its tags and kid info
     $photo = \P4\Photo::with('tags')->find($id);
     if (is_null($photo)) {
         \Session::flash('flash_message', 'Photo not found.');
         return redirect('\\photos');
     }
     # Get kid drop down list
     $kidModel = new \P4\Kid();
     $kids_for_dropdown = $kidModel->getKidsForDropdown();
     # Get tag checkbox group
     $tagModel = new \P4\Tag();
     $tags_for_checkbox = $tagModel->getTagsForCheckboxes();
     # Fill tags for this photo
     $tags_for_this_photo = [];
     foreach ($photo->tags as $tag) {
         $tags_for_this_photo[] = $tag->name;
     }
     return view('photos.edit')->with(['photo' => $photo, 'kids_for_dropdown' => $kids_for_dropdown, 'tags_for_checkbox' => $tags_for_checkbox, 'tags_for_this_photo' => $tags_for_this_photo]);
 }
Ejemplo n.º 4
0
 /**
  *responds to GET /recipes/edit/{id?}
  */
 public function getEdit($id)
 {
     $recipe = \P4\Recipe::with('tags')->find($id);
     $userId = \Auth::id();
     #ensure that recipes exists and belongs to user or redirect them to homepage
     if (is_null($recipe)) {
         \Session::flash('flash_message', 'recipe not found');
         return redirect('/');
     } elseif ($userId != $recipe->user_id) {
         \Session::flash('flash_message', 'you cannot edit someone elses recipe');
         return redirect('/');
     }
     #pull in tags
     $tagModel = new \P4\Tag();
     $tags_for_form = $tagModel->getTagsForForm();
     $tags_for_this_recipe = [];
     foreach ($recipe->tags as $tag) {
         $tags_for_this_recipe[] = $tag->tag_name;
     }
     #show recipe edit form with current values
     return view('recipes.edit')->with(['recipe' => $recipe, 'tags_for_form' => $tags_for_form, 'tags_for_this_recipe' => $tags_for_this_recipe]);
 }