diff --git a/src/Audit.php b/src/Audit.php index 33e5d4b0..8cb4596a 100644 --- a/src/Audit.php +++ b/src/Audit.php @@ -34,13 +34,6 @@ trait Audit */ protected $modified = []; - /** - * Is globally auditing disabled? - * - * @var bool - */ - public static $auditingDisabled = false; - /** * {@inheritdoc} */ diff --git a/src/Auditable.php b/src/Auditable.php index ac258dd3..8b954090 100644 --- a/src/Auditable.php +++ b/src/Auditable.php @@ -259,7 +259,7 @@ protected function getRestoredEventAttributes(): array */ public function readyForAuditing(): bool { - if (static::$auditingDisabled || Audit::$auditingDisabled) { + if (static::$auditingDisabled || Models\Audit::$auditingGloballyDisabled) { return false; } @@ -526,7 +526,7 @@ public function getAuditEvents(): array */ public static function isAuditingDisabled(): bool { - return static::$auditingDisabled || Audit::$auditingDisabled; + return static::$auditingDisabled || Models\Audit::$auditingGloballyDisabled; } /** @@ -562,12 +562,12 @@ public static function withoutAuditing(callable $callback, bool $globally = fals $auditingDisabled = static::$auditingDisabled; static::disableAuditing(); - Audit::$auditingDisabled = $globally; + Models\Audit::$auditingGloballyDisabled = $globally; try { return $callback(); } finally { - Audit::$auditingDisabled = false; + Models\Audit::$auditingGloballyDisabled = false; static::$auditingDisabled = $auditingDisabled; } } diff --git a/src/Models/Audit.php b/src/Models/Audit.php index 62ac6cd3..187b01b9 100644 --- a/src/Models/Audit.php +++ b/src/Models/Audit.php @@ -21,6 +21,13 @@ class Audit extends Model implements \OwenIt\Auditing\Contracts\Audit */ protected $guarded = []; + /** + * Is globally auditing disabled? + * + * @var bool + */ + public static $auditingGloballyDisabled = false; + /** * {@inheritdoc} */