Skip to content

Values are not being audited when using DB::beginTransaction #901

@alexfarrugia

Description

@alexfarrugia
Q A
Bug? maybe
New Feature? no
Framework Laravel
Framework version 9.0.0
Package version 12.0.0
PHP version 8.1

Actual Behaviour

I am making changes to some models which use the Auditable trait within the context of a db transaction. I need to do this because there are chunk of changes which are happening and i need to be able to rollback if something goes wrong. I have noticed that the changes to the values of these models are being audited as empty objects. (see example in this image)
image

Could it be that the audits are happening before the changes are being committed to the database or maybe am i missing something myself?

Expected Behaviour

I would expect that the correct new values are being audited in the database.

Steps to Reproduce

`DB::beginTransaction();
try {
$fund->amount = 5000;
$fund->save();
.....

DB::commit();
}`

Possible Solutions

Not sure if there is a way of delaying the audit until the actual transaction is committed perhaps ? I can't think of any other way to somehow include the audit within the same database transaction?

thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions