[13.x] Fix: add missing check for #[WithoutTimestamps] on model ignore touch - #61073
Merged
Merged
Conversation
|
Thanks for submitting a PR! Note that draft PRs are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
bram-pkg
force-pushed
the
read-withouttimestamps
branch
from
August 6, 2026 10:26
4e97714 to
b2a13b6
Compare
#[WithoutTimestamps] attribute on ignore touch
#[WithoutTimestamps] attribute on ignore touch#[WithoutTimestamps] on model ignore touch
bram-pkg
marked this pull request as ready for review
August 6, 2026 10:28
eas4ai
added a commit
to eas4ai/suprnova
that referenced
this pull request
Aug 19, 2026
Adds the runtime cascade for `#[model(touches = [...])]`: after a child model is created, saved, updated, deleted, or force-deleted, every declared `BelongsTo` owner gets one `UPDATE <owner> SET updated_at = ? WHERE <key> = ?` on the same executor as the triggering write, so it joins an ambient `DB::transaction` and rolls back with it. - `EloquentModel` gains `TOUCHES`, `HAS_TIMESTAMPS`, `UPDATED_AT_COLUMN` consts; `RelationEntry` gains `related_updated_at_column`, collapsed from the target's two consts via the new `touch_column` const fn. - `Model::touch_owners` / `touch_owners_with_tx` / `__touch_owners_via` are new trait-default methods, wired into all 10 write-path call sites (create/save/update/delete/force_delete + the five `_with_tx` shims) and into the soft-delete macro's inherent delete/force_delete overrides. - `without_touching_on::<M, _, _>` adds a per-type suppression scope (Laravel's `withoutTouchingOn`), and the existing `without_touching` now also suppresses the owner cascade, not just direct `.touch()`. - The macro validates `touches` at expansion time: every name must resolve to a declared `BelongsTo` relation, or it's a compile error. - An owner with `timestamps = false` is skipped, not written and not an error (laravel/framework#61073); same for a NULL FK or a soft-deleted owner. - Breaking change: `TOUCHES` moves from an inherent const to `EloquentModel`, since the cascade needs it reachable from a trait default. `Comment::TOUCHES` still resolves with `EloquentModel` in scope. Deliberately out of scope: `restore()` does not touch (Suprnova's restore is a raw UPDATE, not a `save()`), and the cascade is one level deep and event-free (no parent hydration, no grandparent recursion, no parent `saved` event) - both documented in manual/eloquent.md's "Why Suprnova diverges". Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Currently the
#[WithoutTimestamps]attribute is ignored when checking if a model is supposed to be touched, and only#[Table(timestamps: false)]is checked. Behaviour should be the same between these two.