public function destroy($note_id) { $user = Auth::user(); $note = Note::findOrFail($note_id); $note->delete(); return redirect('/home'); }
public function setTop($id, $result, Request $request) { $note = Note::findOrFail($id); $note->istop = $result; $note->save(); return redirect(URL::previous()); }
public function destroy($id) { $note = Note::findOrFail($id); if ($note->delete()) { return response(204); } else { return response(500); } }
public function likeNote($id) { $userId = Auth::user()->id; if (!NoteLike::exists($userId, $id)) { $note = Note::findOrFail($id); $noteLike = new NoteLike(); $noteLike->note_id = $id; $noteLike->user_id = $userId; $noteLike->save(); $note->updateLikes(); return $note->likes; } return -1; }
public function saveNote(Request $request) { $noteid = $request['noteid']; $content = $request['content']; $visibility = $request['visibility']; $user = Auth::user(); $note = new Note(); if ($noteid == '0') { $note->content = $content; $note->visibility = $visibility; $note->user_id = $user->id; $note->save(); return '1'; } $note = Note::findOrFail($noteid); if ($note->user_id == $user->id) { $note->content = $content; $note->visibility = $visibility; $note->save(); return '1'; } }
/** * Attach an element to an outline * * @param int $outlineID The ID describing the outline * @param string $attachmentType 'custom' or 'note' * @param mixed $requestContent int or string depending on $attachmentType * @param int $index The index that this function should assign to the element * @param string $type Only necessary for custom elements, the HTML tag ("p" or "h2") * * @return mixed Response, CustomField or Note depending on params */ public function getOutlineAttach($outlineID, $attachmentType, $requestContent, $index, $type = "p") { // First catch the outline try { $outline = Outline::findOrFail($outlineID); } catch (ModelNotFoundException $e) { return response()->json(['message', 'Could not find outline'], 404); } if ($attachmentType == "custom") { $field = new CustomField(); $field->type = $type; // type is the HTML tag (i.e. p, h3, div) $field->content = nl2br($requestContent); // What goes inside the tag $field->index = $index; // The index inside the outliner $outline->customFields()->save($field); return $field; } else { // attachmentType = note // $type is now omittable // $requestContent now contains our ID try { $note = Note::findOrFail($requestContent); } catch (ModelNotFoundException $e) { return response()->json(['message', 'Could not find note'], 404); } $outline->notes()->attach($note, ['index' => $index]); return $note; } }
public function storeComments(CommentRequest $request, $id) { $note = Note::findOrFail($id); $comment = new NoteComment(); $comment->user_id = Auth::user()->id; $comment->content = ubbReplace($request->input('content')); $comment->note_id = $id; $comment->save(); Note::updateCommentCount($note); return redirect('notes/' . $id . '#comments'); }
/** * @TODO:Fix this download link * @param $id * @return \Symfony\Component\HttpFoundation\BinaryFileResponse */ public function download($id) { $note = Note::findOrFail($id); return \Response::download(storage_path('pdf/') . $note->url, $note->name . ".pdf", ['Content-Type' => 'document/pdf']); }
/** * Removes a note from database * * @param integer $id Note id * * @return Response */ public function delete($id) { try { $note = Note::findOrFail($id); } catch (ModelNotFoundException $e) { // Didn't find the note? Tell the user. return redirect('/notes/index')->withErrors(['No note with specified ID found.']); } $note->delete(); return redirect(url('/notes/index')); }
public function supprimerNote($id, $back) { // $note = Note::findOrFail($id); $note->update(['etat' => 0]); $id = $note->contact_id; if ($back == 0) { # code... return redirect(route('contact.show', $id)); } else { # code... return redirect(route('notes.index')); } }
public function saveNote(Request $request, $territoryId = null, $noteId = null) { if (!$this->hasAccess($request)) { return Response()->json(['error' => 'Access denied.'], 500); } if (empty($territoryId)) { return ['error' => 'Territory not found', 'message' => 'Territory not found']; } if (!empty($noteId)) { $note = Note::findOrFail($noteId); if (Gate::denies('update-notes', $note)) { return Response()->json(['error' => 'Method not allowed'], 403); } // dd($this->unTransform($request->all(), 'note')); try { $data = $note->update($this->unTransform($request->all(), 'note')); } catch (Exception $e) { $data = ['error' => 'Note not updated', 'message' => $e->getMessage()]; } } else { $data = ['error' => 'Note not found', 'message' => 'Note not found']; } return ['data' => $data]; }