Search code examples
laravelmodellaravel-auditing

Is there any way to specify a specific user when auditing a Model?


Expected Behaviour

I'm auditing the Product model currently but I just want to audit the model when a specific user makes any change, is there any way I could achieve this?

Possible Solutions

It would be great if the Developer get the control to set the particular set of userID on Model as

protected $user_ids = [1,2,3];

  • Framework | Laravel
  • Framework version | 7.x
  • Package Name | owen-it/laravel-auditing
  • Package version | 11.0
  • PHP version | 7.3

Solution

  • You could try listening for the auditing event, OwenIt\Auditing\Events\Auditing, that this package fires off. You could check what you need to at that point and return false from the listener if you want it to not do the audit.