Exemple #1
0
 /**
  * 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;
 }
 /**
  * Creates a note and stores it in the database
  *
  * This method uses the note repository to create a new note to the
  * database with user, project, content and deadline.
  *
  * @since 1.0.0
  *
  * @param Request $request The HTTP request with the data of the note
  * @return int The HTTP status code
  */
 public function store(Request $request)
 {
     return $this->notes->createNote($request);
 }
 /**
  * Delete a record
  * @param  mixed $id
  * @return Response
  */
 public function destroy($id)
 {
     // Later, make sure resource exist and user is authorized
     $this->noteRepository->delete($id);
 }