Skip to content

Commit 2d1e4bf

Browse files
cosmastecherikn69
andauthored
Allow for creating an Auditable model even if application is not spun up (#962)
* unlint * ends with new line * Check facade instance --------- Co-authored-by: erikn69 <[email protected]>
1 parent 8155c26 commit 2d1e4bf

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/Auditable.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ trait Auditable
7575
*/
7676
public static function bootAuditable()
7777
{
78-
if (static::isAuditingEnabled()) {
78+
if (App::getFacadeRoot() && static::isAuditingEnabled()) {
7979
static::observe(new AuditableObserver);
8080
}
8181
}
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace OwenIt\Auditing\Tests\Unit;
4+
5+
use OwenIt\Auditing\Tests\Models\Article;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class OutsideOfAppContextTest extends TestCase
9+
{
10+
public function test_can_create_new_model(): void
11+
{
12+
$article = new Article();
13+
$this->assertInstanceOf(Article::class, $article);
14+
}
15+
}

0 commit comments

Comments
 (0)