Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
PHPORM-180 Trigger events in Model::createOrFirst #2980
PHPORM-180 Trigger events in Model::createOrFirst #2980
Changes from all commits
7d3c406
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall the original reason for introducing
createOrFirst()
in #2742 (PHPORM-139). It looks like this was necessary to avoid some issue with transactions.Just wanted to confirm that a custom implementation is still required at all, given that we'll no longer be using
findAndModify
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still using
findAndModify
, but inQuery\Builder::findAndModify
.The call chain is:
Model::createOrFirst
Eloquent\Query::createOrFirst
Model::saveOrFirst
Query\Builder::findAndModify
Collection::findAndModify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume much of the contents for this method were lifted from an existing method in Eloquent. If so, can we reference that in the method doc block?
I'm a little worried that if anything changes upstream we'll probably need to find out the hard way that this needs to be updated, but that may be unavoidable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also concerned that we have a lot of duplicated code that is hard to understand and we are not sure we can maintain in the long-term.
Creating a simple alternative PR: #2984
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does the comment above refer to
insertGetId()
? It's not clear to me how that's getting used here, unless it's throughgetAttributesForInsert()
.Does
getAttributesForInsert
respect modifications from earlier model methods such assetUniqueIds()
andupdateTimestamps()
? I assume this all pulls from the same state.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for inheriting the query's connection? IS this necessary for dispatching the
created
event?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any reference to a
saved
method. Is this comment accurate?