Skip to content

Commit

Permalink
[5.4] Notification Channels Array Cast (#18960)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
ConnorVG authored and taylorotwell committed Apr 27, 2017
1 parent 07d04bd commit de0c022
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Notifications/NotificationSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit de0c022

Please sign in to comment.