Skip to content
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

[Request] Swap $model->update([..., 'updated_at' => DB::raw('updated_at')]) for Model::withoutTimestamps(fn () => $model->update([...])) #4298

Open
Roardom opened this issue Nov 1, 2024 · 2 comments
Labels

Comments

@Roardom
Copy link
Contributor

Roardom commented Nov 1, 2024

Probably should refactor all of these at some point to use the idiomatic syntax.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@Roardom Roardom added Fund https://polar.sh Request labels Nov 1, 2024
@IonBazan
Copy link
Contributor

IonBazan commented Nov 1, 2024

We can also do updateQuietly - this however prevents all model events/observers from being triggered (including Auditable).

@Roardom
Copy link
Contributor Author

Roardom commented Nov 2, 2024

We can also do updateQuietly - this however prevents all model events/observers from being triggered (including Auditable).

Thanks for the alternative. In most cases that this hack is used, it's for bulk updates that don't send model events/observers anyways, so that shouldn't be an issue. However, if the goal is to not update the updated_at timestamp, then it's probably better to call a function named withoutTimestamps. We also generally try and avoid relying on too many model events/observers so that we can have more freedom to optimize our database queries.

@HDVinnie HDVinnie removed the Fund https://polar.sh label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants