Skip to content

Can I use separate audit table for each model ? #800

Answered by erikn69
webosdeveloper asked this question in Q&A
Discussion options

You must be logged in to vote

@MortenDHansen I do it by changing the config on the fly, I don't know if it's the best way, but it has worked for me for years without problems, example: (it could be a trait)

namespace App;

class AbstractModel extends \Illuminate\Database\Eloquent\Model implements \OwenIt\Auditing\Contracts\Auditable{
    use \OwenIt\Auditing\Auditable;
    
    public static function boot() {
        parent::boot();
        self::creating(function($model) {
            self::setAuditTable($model);
        });
        self::updating(function($model) {
            self::setAuditTable($model);
        });
        self::deleting(function($model) {
            self::setAuditTable($model);
        });
        

Replies: 9 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by parallels999
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
8 participants
Converted from issue

This discussion was converted from issue #653 on March 15, 2023 14:29.