/** * view recipe * @param null $one */ public function getRecipe($one = null) { // アクセス保存 $this->analytics->setCount($one); // recipe取得 $recipe = $this->recipe->getRecipe($one); $recipe->category = $this->category->getCategory($recipe->category_id); $data = ['recipe' => $recipe, 'tags' => $this->tag->getRecipeTags($recipe->recipe_id), 'info' => $this->recipe->getPrevNextRecipes($one)]; // title設定 $this->title($recipe->title); $this->description($recipe->problem); $this->view('home.recipe.index', $data); }
/** * @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 } } } }