Пример #1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     $article = new Article();
     $tags = $this->tagRepository->all()->lists('name', 'id');
     $categories = $this->categoryRepository->all()->lists('name', 'id');
     $selectedTags = $article->tags()->lists('id')->toArray();
     return view('cms.articles.create', compact('tags', 'categories', 'article', 'selectedTags'));
 }
Пример #2
0
 /**
  * Assign tags to the given article.
  *
  * @param Article $article
  * @param $tagIds
  * @return mixed
  */
 public function assignTags(Article $article, array $tagIds)
 {
     $article->tags()->sync($tagIds);
     return $article->save() ? $article : false;
 }