Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrapped mass assignment with unguarded models #431

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dennis-koster
Copy link

When using the translations_wrapper config option in combination with a model factory, an SQL error is thrown.

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 table vegetables has no column named _translation_wrapper (Connection: testing, SQL: insert into "vegetables" ("quantity", "_translation_wrapper", "updated_at", "created_at") values (5, ?, 2024-09-16 08:52:41, 2024-09-16 08:52:41))

This has to do with the fact that eloquent model factories unguard the model before performing a mass assignment. The wrapped attribute is not removed from the attributes array so an attempt is made to insert that into the base model as wel.

This MR fixes that issue. I have accompanied the proposed code with a test to demonstrate its proper functioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant