$todos]); } public function store(Request $request) { $validated = $request->validate([ 'task' => 'required|string|max:255' ]); $todo = Todo::create([ 'task' => $validated['task'] ]); return response()->json($todo); } public function destroy($id) { $todo = Todo::findOrFail($id); $todo->delete(); return response()->json(['message' => 'Task deleted successfully']); } }