Skip to content

Commit

Permalink
feat: Allow share default namespace to be changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nikuscs committed Jun 1, 2024
1 parent 07e3ec6 commit 8e473b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/inertia-flash.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

// Defaults for the notification
'defaults' => [
'namespace' => 'flashNotifications',
'read_route' => 'notification.read',
'type' => Flavorly\InertiaFlash\Notification\Enums\NotificationTypeEnum::Flash,
'level' => Flavorly\InertiaFlash\Notification\Enums\NotificationLevelEnum::Info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait HasNotificationDataViaChannel
/**
* The namespace where the notification will be dispatched when sharing with inertia
*/
public string $viaInertiaNamespace = 'notifications';
public ?string $viaInertiaNamespace = null;

/**
* Routes the notification to the given channel, defaults to Broadcast & Database
Expand Down
3 changes: 2 additions & 1 deletion src/Notification/Concerns/HasNotificationDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ protected function dispatchViaInertia(): void
// Noop, we dont want to share via Inertia on console
if ($this->via->contains(NotificationViaEnum::Inertia) || $this->via->contains('inertia')) {
inertia_flash()->append(
$this->viaInertiaNamespace,
// @phpstan-ignore-next-line
$this->viaInertiaNamespace ?? config('inertia-flash.notifications.defaults.namespace', 'flashNotifications'),
$this->toArray()
);
}
Expand Down

0 comments on commit 8e473b1

Please sign in to comment.