orderByDesc('updated_at') ->get(); return view('notes.index', compact('notes')); } public function store(Request $request): JsonResponse { $data = $request->validate([ 'title' => 'required|string|max:255', 'content' => 'nullable|array', 'color' => 'nullable|string|max:20', 'is_pinned' => 'boolean', ]); $note = Note::create($data); return response()->json($note, 201); } public function update(Request $request, Note $note): JsonResponse { $data = $request->validate([ 'title' => 'required|string|max:255', 'content' => 'nullable|array', 'color' => 'nullable|string|max:20', 'is_pinned' => 'boolean', ]); $note->update($data); return response()->json($note); } public function destroy(Note $note): JsonResponse { $note->delete(); return response()->json(['ok' => true]); } public function togglePin(Note $note): JsonResponse { $note->update(['is_pinned' => ! $note->is_pinned]); return response()->json($note); } }