Skip to content

Commit 4c68478

Browse files
committed
Register observer in the whenBooted callback for Laravel 13.x
1 parent 63917d8 commit 4c68478

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/Models/Broadcasts.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ trait Broadcasts
2121

2222
public static function bootBroadcasts(): void
2323
{
24-
static::observe(new ModelObserver);
24+
if (method_exists(static::class, 'whenBooted')) {
25+
static::whenBooted(function () {
26+
static::observe(new ModelObserver);
27+
});
28+
} else {
29+
static::observe(new ModelObserver);
30+
}
2531
}
2632

2733
public static function withoutTurboStreamBroadcasts(callable $callback)

0 commit comments

Comments
 (0)