You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes is need to disable auditing for one model temporarily, for example when doing some big imports and auditing for every row is not necessary.
For example:
Customer::disableAuditing();
foreach($thousandsImportedCustomers as $importedCustomer){
Customer::create($data); // don't want to audit this here
}
Customer::enableAuditing();
Possible Solutions
I am doing it via additional trait at moment but you could just add something like that to have it right out of the box :)
public static $auditingDisabled = false;
public static function isAuditingEnabled(): bool
{
if (self::$auditingDisabled) {
return false;
}
if (App::runningInConsole()) {
return Config::get('audit.console', false);
}
return true;
}
public static function disableAuditing()
{
self::$auditingDisabled = true;
}
public static function enableAuditing()
{
self::$auditingDisabled = false;
}
The text was updated successfully, but these errors were encountered:
Expected Behaviour
Sometimes is need to disable auditing for one model temporarily, for example when doing some big imports and auditing for every row is not necessary.
For example:
Possible Solutions
I am doing it via additional trait at moment but you could just add something like that to have it right out of the box :)
The text was updated successfully, but these errors were encountered: