Skip to content

Commit 5f48872

Browse files
authored
Fix unable to parse string notifiable (#974)
1 parent b9b7166 commit 5f48872

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/Sentry/Laravel/Features/NotificationsIntegration.php

+13-5
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,22 @@ public function handleNotificationSent(NotificationSent $event): void
7676
}
7777
}
7878

79-
private function formatNotifiable(object $notifiable): string
79+
private function formatNotifiable($notifiable): string
8080
{
81-
$notifiable = get_class($notifiable);
81+
if (is_string($notifiable) || is_numeric($notifiable)) {
82+
return (string)$notifiable;
83+
}
84+
85+
if (is_object($notifiable)) {
86+
$result = get_class($notifiable);
87+
88+
if ($notifiable instanceof Model) {
89+
$result .= "({$notifiable->getKey()})";
90+
}
8291

83-
if ($notifiable instanceof Model) {
84-
$notifiable .= "({$notifiable->getKey()})";
92+
return $result;
8593
}
8694

87-
return $notifiable;
95+
return 'unknown';
8896
}
8997
}

0 commit comments

Comments
 (0)