Skip to content

Commit

Permalink
Check facade instance
Browse files Browse the repository at this point in the history
  • Loading branch information
erikn69 authored Jan 13, 2025
1 parent 84e9907 commit 612e3f0
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions src/Auditable.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,7 @@ trait Auditable
*/
public static function bootAuditable()
{
try {
$isAuditingEnabled = static::isAuditingEnabled();
} catch (\RuntimeException $e) {
if ($e->getMessage() !== 'A facade root has not been set.') {
throw $e;
}

/**
* Facade root has not been set. The user may be attempting to use
* their Auditable outside of the application context. We will
* just skip booting for now.
*/
return;
}

if ($isAuditingEnabled) {
if (App::getFacadeRoot() && static::isAuditingEnabled()) {
static::observe(new AuditableObserver());
}
}
Expand Down

0 comments on commit 612e3f0

Please sign in to comment.