Repository: owen-it/laravel-auditing (language: php)

Issue:
Database allows null in old/new_values, but Audit::resolveData errors out if they are
### PHP Version

8.3

### Laravel Version

11.15

### Package Version

13.6.8

### Description

The migration for the audits table defines old_ and new_values as nullable, but if an Entry exists that has either `null`, `Audit::resolveData` errors out when trying to iterate over them.

### Steps To Reproduce

- Create an Audit record where either old_values or new_values is `null`. One way this is currently possible is by dispatching a custom audit event and not set either `$instance->customAuditOld` or `$instance->customAuditNew`
- Call `resolveData` on the created Audit instance

### Possible Solutions

in `\OwenIt\Auditing\Audit`:104:
```php
        // Modified Auditable attributes
        foreach ($this->new_values ?? [] as $key => $value) {
            $this->data['new_' . $key] = $value;
        }

        foreach ($this->old_values ?? [] as $key => $value) {
            $this->data['old_' . $key] = $value;
        }
```


Discussion / hints:
Makes sense to me, would you like to make a PR?
Sure

Fix patch:
diff --git a/src/Audit.php b/src/Audit.php
index 8cb4596a..a99d80fa 100644
--- a/src/Audit.php
+++ b/src/Audit.php
@@ -102,11 +102,11 @@ public function resolveData(): array
         $this->metadata = array_keys($this->data);
 
         // Modified Auditable attributes
-        foreach ($this->new_values as $key => $value) {
+        foreach ($this->new_values ?? [] as $key => $value) {
             $this->data['new_' . $key] = $value;
         }
 
-        foreach ($this->old_values as $key => $value) {
+        foreach ($this->old_values ?? [] as $key => $value) {
             $this->data['old_' . $key] = $value;
         }
 


Test patch: