Comments (4)
Maybe it's because update
uses dirty
, and after saving, dirty
is empty
Try this way
$article->title = $newTitle;
event('eloquent.updated: App\Models\Article', $article);
$article->saveQuietly();
from laravel-auditing.
Thanks, that does the trick. But it kinda defeats the purpose of not firing events on save. We do fire the events after the business logic block. Something like this:
$article->title = $newTitle;
$article->saveQuietly();
$events[] = ['updated', 'App\Models\Article', $article];
$user->restoreQuietly();
$events[] = ['restored', 'App\Models\User', $user];
... a bunch of other operations without events while saving event data
// then fire the events
foreach ($events as $event) {
event('eloquent.' . $event[0] . ': ' . $event[1], $event[2]);
}
from laravel-auditing.
Did you try clone
before save??
$article->title = $newTitle;
$events[] = ['updated', 'App\Models\Article', clone $article];
$article->saveQuietly();
I can't give you a specific answer if you don't specify the full scenario
from laravel-auditing.
Using clone
on the event works, thank you.
from laravel-auditing.
Related Issues (20)
- ArrayObject::__construct() TypeError
- auditSync - writes an empty array when there is no data change HOT 1
- Error when saving characters in Spanish HOT 5
- Call to undefined method Model::toAudit()
- I have PHP 8.1 and Laravel 10. My error is in the Model: Undefined type: "\OwenIt\Auditing\Auditable" HOT 17
- Automatic auditing of attach/detach for BelongsToMany HOT 7
- Record non modified fields HOT 3
- Serialization of 'PDO' is not allowed - Queued Audits HOT 9
- The [sync] queue connection has not been configured. HOT 5
- Excessive Queue job logged when use with batch import of large amount of data (#846) HOT 3
- Enabling queue causes Unable to JSON encode payload. Error (5) HOT 7
- Audit excludes fields records are creating in table HOT 3
- Class "Request" not found HOT 1
- The events (DispatchAudit) are missing the SerializesModels trait HOT 9
- Serialization of 'Closure' is not allowed HOT 7
- ErrorException: Undefined array key "table" in /vendor/laravel/framework/src/Illuminate/Queue/Connectors/DatabaseConnector.php:38 HOT 1
- Binary attribute casting no longer works in new versions (works flawlessly with v13.5.1) HOT 5
- Duplicate entries for every action HOT 8
- Values are not being audited when using DB::beginTransaction HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-auditing.