owen-it / laravel-auditing

Record the change log from models in Laravel
https://laravel-auditing.com
MIT License
3.05k stars 390 forks source link

fix: RecordCustomAudit listener #963

Open Pr3d4dor opened 3 months ago

Pr3d4dor commented 3 months ago

This pull request fixes this problem:

OwenIt\Auditing\Listeners\RecordCustomAudit::handle(): Argument #1 ($model) must be of type OwenIt\Auditing\Contracts\Auditable, OwenIt\Auditing\Events\AuditCustom given, called in /mnt/c/Users/bine/Documents/mapos-laravel/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php on line 478 
willpower232 commented 3 months ago

I'm assuming that fixing these tests also makes sense as well as correcting the listener

Pr3d4dor commented 3 months ago

@willpower232 There is a strange behavior, maybe there is a bug in the Laravel core.

This does not work:

Event::dispatch(AuditCustom::class, [$this]);

But this works:

Event::dispatch(new AuditCustom($this));