-
Notifications
You must be signed in to change notification settings - Fork 784
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
[10.x] ClientFactory breaks when using UUIDs and quiet creation #1491
Comments
Hmm, yes I see what you mean. This indeed doesn't plays nicely with each other. Maybe we can do both? First send in your current non breaking change to 10.x so it's fixed on the current stable release and then afterwards when we get that into master send in a PR to remove the event behavior from the model. I'm not sure what the exact changes would be so if there's many there's a chance that Taylor might not accept them. But I think it's worth exploring this. Thanks! |
I'm going to close this because I technically don't consider this a bug but rather a limitation. Still want to thank you for reporting it and welcoming your PR if you want to send that in. |
Edit: nevermind I overlooked your first comment, will be sending PRs shortly |
Description:
Laravel 8.59 introduced the ability to create models quietly (without events) using model factories. Because Laravel Passport currently uses a model event listener to set a UUID on the Client model, Passport's model factory will fail to create client models when using both quiet creation and the UUIDs option.
Example error:
Steps To Reproduce:
Possible fixes:
One way to address this would be to move the UUID check out of the model event listener and into the
ClientFactory
andClientCommand
. This would make Passport's client model behave like any other model that has a non-incremental primary key, in that you would always have to explicitly define it before inserting the model into the database. I propose making this change on master as people might be relying on current behaviour in their applications.Another solution could be to build a fallback into the model factory, by leaving the model event listener as it is and also adding the check to the model factory. This would have the added benefit of being a non-breaking change (as far as I can tell), but the downside of having the same check in two places.
I'm able to make a PR for either change (or another fix) if any are deemed necessary/acceptable.
The text was updated successfully, but these errors were encountered: