validate([ 'content' => 'required|string|max:1000', 'commentable_id' => 'required|integer', 'commentable_type' => 'required|string', ]); $comment = Comment::create([ 'user_id' => auth()->id(), 'content' => $validated['content'], 'commentable_id' => $validated['commentable_id'], 'commentable_type' => $validated['commentable_type'], ]); return back()->with('success', 'Commentaire ajouté.'); } }