Route::put('save-edits/{note_id}', [NotesController::class, 'saveEdits']) -> name('saveEdits');
public function saveEdits(Request $request, $note_id) { $noteContent = $request->input('note_content'); $note = notes::find($note_id); if (!$note) { return response()->json(['error' => 'Note not found!'], 404); } $note->note = $noteContent; $note->save(); return view('modal', ['note' => $note]); }
<div class="modal fade" id="noteModal"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title">Edit Notes</h5> <button type="button" class="close" data-dismiss="modal"><span>×</span> </button> </div> <div class="modal-body"> <form method="PUT" id="saveEditsForm" action="{{ route('save-edits', ['note_id' => $note->note_id]) }}" > @method('PUT') @csrf <textarea name="note_content" id="noteContent" cols="30" rows="5" class="form-control bg-transparent" title="Please edit your note" required> </textarea> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> <button type="submit" class="btn btn-primary" >Save changes</button> </div> </form> </div> </div> </div> </div>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)