Add saveQuietlyOrFail(), updateQuietlyOrFail(), deleteQuietlyOrFail() to Eloquent Model #59450
Unanswered
Anne-Willems
asked this question in
Ideas
Replies: 1 comment
-
|
One small suggestion for public function deleteQuietlyOrFail()
{
return static::withoutEvents(fn () => $this->deleteOrFail());
}Also worth considering — a public function forceDeleteQuietlyOrFail()
{
return static::withoutEvents(fn () => $this->forceDeleteOrFail());
}Overall, this is a clean, consistent addition. The naming reads naturally, the implementation is minimal, and it fills a real gap. The current workaround of wrapping manually in +1 from me, would love to see this in the framework. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to propose a small improvement for Eloquent models.
There is already a identical discussion: #41283
But that one is a few years old and lacks the code suggestions.
Laravel currently has:
But there is no
quietvariant for: 'saveOrFail' & 'updateOrFail' & 'deleteOrFail.Because of that, when you want both behaviors together, you currently need to write:
A dedicated method would make this cleaner and more expressive.
Suggested name:
Possible implementation:
File: laravel/framework/src/Illuminate/Database/Eloquent/Model.php
Reasoning:
Beta Was this translation helpful? Give feedback.
All reactions