From 981107ed450fd24387b6ff4025815c85beadc05e Mon Sep 17 00:00:00 2001 From: "Connor S. Parks" Date: Thu, 27 Apr 2017 09:14:24 +0100 Subject: [PATCH] [5.4] Notification Channels Array Cast 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) --- src/Illuminate/Notifications/NotificationSender.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Notifications/NotificationSender.php b/src/Illuminate/Notifications/NotificationSender.php index 7cc517566a84..7e447bdbd39c 100644 --- a/src/Illuminate/Notifications/NotificationSender.php +++ b/src/Illuminate/Notifications/NotificationSender.php @@ -85,7 +85,7 @@ public function sendNow($notifiables, $notification, array $channels = null) continue; } - foreach ($viaChannels as $channel) { + foreach ((array) $viaChannels as $channel) { $this->sendToNotifiable($notifiable, $notificationId, clone $original, $channel); } }