/** * Handle the editing of a tag. * * @param mixed $id * * @return \Illuminate\Http\RedirectResponse */ public function postView($id) { $form = $this->tags->getForm(); if (!$form->isValid()) { return $this->redirectRoute('admin.tags.view', $id)->withErrors($form->getErrors())->withInput(); } $tag = $this->tags->update($id, $form->getInputData()); return $this->redirectRoute('admin.tags.view', $id); }
/** * Show the edit trick page. * * @param string $slug * * @return \Response */ public function getEdit($slug) { $trick = $this->trick->findBySlug($slug); $tagList = $this->tags->listAll(); $categoryList = $this->categories->listAll(); $selectedTags = $this->trick->listTagsIdsForTrick($trick); $selectedCategories = $this->trick->listCategoriesIdsForTrick($trick); return view('tricks.edit', ['tagList' => $tagList, 'selectedTags' => $selectedTags, 'categoryList' => $categoryList, 'selectedCategories' => $selectedCategories, 'trick' => $trick]); }
/** * @param $recipeId * @param string $string */ protected function addTags($recipeId, $string = '-') { if ($string != '-' && $string != '') { $tags = explode(',', $string); foreach ($tags as $tag) { try { $tagId = $this->tag->addTag(['tag_name' => trim($tag)]); } catch (QueryException $e) { $tag = $this->tag->getTagFromName(trim($tag)); $tagId = $tag->tag_id; } try { $this->recipeTag->addRecipeTag(['tag_id' => $tagId, 'recipe_id' => $recipeId]); } catch (QueryException $e) { // no process } } } }
/** * Get all the tags to include in the sitemap. * * @return \Illuminate\Database\Eloquent\Collection|\App\Tag[] */ public function getTags() { return $this->tags->findAll(); }
/** * Show the tags index. * * @return \Response */ public function getTagIndex() { $tags = $this->tags->findAllWithTrickCount(); return view('browse.tags', compact('tags')); }