Ejemplo n.º 1
0
 /**
  * Update a note in the database
  *
  * @param $uuid
  * @param $params
  * @return mixed
  */
 public function update($uuid, $params)
 {
     $note = $this->noteRepository->findByUuid($uuid);
     foreach ($params as $key => &$param) {
         if ($key == 'type') {
             $param = constant('Knoters\\Models\\NoteType::' . strtoupper($param));
         } else {
             if ($key == 'items') {
                 $this->saveNoteItems($note->id, $param);
                 unset($params['items']);
             }
         }
     }
     return $this->noteRepository->update($note->id, $params);
 }
Ejemplo n.º 2
0
 /**
  * Store a new reply to the database
  *
  * @param $data
  * @return static
  * @throws \Exception
  */
 public function store($data)
 {
     $note = $this->noteRepository->findByUuid($data['noteUuid'], [], ['id']);
     return $this->replyRepository->store(['note_id' => $note->id, 'index' => $data['index'], 'from_id' => user()->id, 'uuid' => (string) Uuid::generate(4)]);
 }