Skip to content

Commit de0c022

Browse files
ConnorVGtaylorotwell
authored andcommitted
[5.4] Notification Channels Array Cast (#18960)
We document that notifications can return a `string` from their `via` method but doing so causes an error. This is an issue that I see cropping up quite often with people getting stuck on 'my notification is erroring' but they're just returning the class like so: ```php /** * Get the notification's channels. * * @param mixed $notifiable * @return array|string */ public function via($notifiable) { return MyChannel::class; } ``` Which they don't expect to error because of the docblock. The same docblock also appears in the documentation. [ResetPassword notification](https://github.com/laravel/framework/blob/5.4/src/Illuminate/Auth/Notifications/ResetPassword.php#L32) [Custom Channel Documentation](https://laravel.com/docs/5.4/notifications#custom-channels)
1 parent 07d04bd commit de0c022

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Illuminate/Notifications/NotificationSender.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function sendNow($notifiables, $notification, array $channels = null)
8585
continue;
8686
}
8787

88-
foreach ($viaChannels as $channel) {
88+
foreach ((array) $viaChannels as $channel) {
8989
$this->sendToNotifiable($notifiable, $notificationId, clone $original, $channel);
9090
}
9191
}

0 commit comments

Comments
 (0)