-
Notifications
You must be signed in to change notification settings - Fork 11.3k
[9.x] Add Model::withoutTimestamps(...) #44138
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
Conversation
I suspect this implementation will not work as expected with nested calls to
You can imagine one would call |
I don't think it was ever intended to work with nested calls? @timacdonald |
I did not intend for it to be used this way. Would recommend not nesting calls to this or the other methods that work this way. |
Yeah, I've run into this before. Disabling timestamps is a tricky beast and heavily dependent on the use case. |
I had my own implementation of withoutTimestamps on trait that was working differently and I think the current approach is not very helpful. On a single model
Updating all models by using a relationship
|
Wouldn't both example be possible like this? Model::withoutTimestamps(fn () => $model->update([ 'included' => true ])); SubTask::withoutTimestamps(fn () => $task->subTasks()->update([ 'included' => false ])); |
See @dennisprudlo suggestion above, and also see the previous PR where the method was not static for future discussion: #44005 |
Re-submission of #44005 as static methods.
API now matching the static nature of
withoutTouching
, but hopefully with a simpler implementation than previous attempts at this functionality.