在Laravel中添加用于广播通知的自定义私人频道

时间:2019-08-12 22:53:50

标签: php laravel laravel-5

广播有效,但是它使用notifiable_type作为带有用户ID的频道名称。但是,如果我只想在后端api上更改某个模型在10个子文件夹中的话该怎么办。我将需要在前端的任何地方更改该频道...

从文档中我发现了这一点

/**
 * The channels the user receives notification broadcasts on.
 *
 * @return string
 */
public function receivesBroadcastNotificationsOn()
{
    return 'users.'.$this->id;
}

但是它不起作用,它仍然使用notifiable_type作为频道名称。我该如何更改?

1 个答案:

答案 0 :(得分:0)

您可以为每个可通知实体指定任何自定义渠道名称。因此,如果您使用<languages> <welcome> <en>welcome</en> <ge>willkommen</ge> </welcome> </languages> 模型:

User

如果您正在使用队列,请确保update/restart your queue jobs