/** * Store a newly created resource in storage. * * @param TagRequest $request * @return Response */ public function store(TagRequest $request) { $input = $request->all(); $this->tagRepository->store($input); Flash::message('Tag created'); return Redirect()->route('tags'); }
/** * Create an Item, its derived class, tags, and reset the main page cache * * @param $inputs * @return Item $item */ public function create($inputs, $user) { // Create the item $item = $this->itemsRepo->store($inputs, $user); // Save Tags $tags = $this->tagsRepo->store($inputs, $user); if (count($tags)) { // Attach Tags to the Item $item->tags()->attach($tags); } // Create the derived type switch ($inputs['type']) { case 'Link': // Create the Link $link = $this->linksRepo->store($inputs); // Associate it to the Item $link->item()->save($item); // Save it to the search index $this->searchHandler->add($link); break; case 'Note': // Create the Note $note = $this->notesRepo->store($inputs); // Associate it to the Item $note->item()->save($item); // Save it to the search index $this->searchHandler->add($note); break; } // Reset caches $this->cacheHandler->del(CacheHandlerInterface::MAINPAGE); $this->cacheHandler->del(CacheHandlerInterface::TAGS); return $item; }
public function store(PostRequest $request, TagRepository $tagRepository) { $inputs = array_merge($request->all(), ['user_id' => $request->user()->id]); $post = $this->postRepository->store($inputs); if (isset($inputs['tags'])) { $tagRepository->store($post, $inputs['tags']); } return redirect(route('post.index')); }