diff --git a/src/Announce.php b/src/Announce.php index 0d6ed6e..d66ab80 100644 --- a/src/Announce.php +++ b/src/Announce.php @@ -21,7 +21,9 @@ class Announce extends Notification protected Alignment | string | Closure | null $bodyAlignment = null; - public function announceTo(Model | Authenticatable | Collection | array $users, ?array $metadata = null): void + protected array | null $metadata = null; + + public function announceTo(Model | Authenticatable | Collection | array $users): void { if (!$this->getColor()) { $this->color(app(FilamentAnnounce::class)->getColor()); @@ -34,8 +36,8 @@ public function announceTo(Model | Authenticatable | Collection | array $users, foreach ($users as $user) { $data = $this->getDatabaseMessage(); - if ($metadata) { - $data['metadata'] = $metadata; + if ($this->metadata) { + $data['metadata'] = $this->metadata; } $notification = new AnnounceNotification($data); @@ -44,6 +46,15 @@ public function announceTo(Model | Authenticatable | Collection | array $users, } } + public function metadata(array $metadata): static + { + if (count($metadata) > 0) { + $this->metadata = $metadata; + } + + return $this; + } + public function disableCloseButton(bool | Closure $condition = true): static { $this->closeButton = !$condition;