Home > Enterprise >  How can I disable multiple logs in Spatie ActivityLog?
How can I disable multiple logs in Spatie ActivityLog?

Time:05-02

I am using Spatie ActivityLog Package for recording logs in my laravel application. I have added default LogActivity in all my models. Now there is a situation for eg: When I add item stock from stock module 2 crud operations takes place,

  1. Stock insert in stock table.
  2. Item quantity update in item table.

As we know by default 2 logs get generated. But I want only 1 log to be recorded for stock insert operation as it is done by user. How can I disable Item update log here ?

CodePudding user response:

If I well understand you want to choose what Spatie Activity Log will log.

I think you can use this option if it is possible in your code :

activity()->withoutLogs(function () {
    // ...
});

This is described in the documentation here : https://spatie.be/docs/laravel-activitylog/v4/advanced-usage/disabling-logging

Tell me if this answer helped you.

Have a nice day.

  • Related