validate([ 'content' => 'required|string', 'parent_id' => 'nullable|exists:comments,id', ]); $comment = Comment::create([ 'post_id' => $post->id, 'user_id' => auth()->id(), 'parent_id' => $validated['parent_id'] ?? null, 'content' => $validated['content'], ]); return back()->with('success', 'Comment posted successfully!'); } public function destroy(Comment $comment) { if ($comment->user_id !== auth()->id()) { abort(403); } $comment->delete(); return back()->with('success', 'Comment deleted successfully!'); } }