Repository navigation
[9.x] Add Model::withoutTimestamps(...) - #44138
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.