Skip to content

Conversation

@riesjart
Copy link
Contributor

@riesjart riesjart commented Nov 4, 2025

#57600 introduced an insert method for the Eloquent model factory.

I don't think it should call Model::toArray() to collect the model attributes for insertion. For multiple reasons, one of them being toArray() will also include any loaded relations.

I think calling Model::getAttributesForInsert() instead would be preferred, but since this method is protected and only calls Model::getAttributes(), I chose the latter. I think it might be better to make getAttributesForInsert() public if there's no objection to that.

@cosmastech
Copy link
Contributor

That seems to make sense. It would prevent Model's defined that have $with and $withCount issues, right? Should we add a test for this to prevent regressions?

@taylorotwell taylorotwell merged commit 08f12a0 into laravel:12.x Nov 5, 2025
68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants