Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

[Proposal] Allow custom notification type and channel names #162

Closed
fgambino opened this issue Aug 19, 2016 · 2 comments
Closed

[Proposal] Allow custom notification type and channel names #162

fgambino opened this issue Aug 19, 2016 · 2 comments

Comments

@fgambino
Copy link

fgambino commented Aug 19, 2016

Currently, all broadcast notifications construct the channel name like this:

$class = str_replace('\\', '.', get_class($this->notifiable));

return $class.'.'.$this->notifiable->getKey();

It would be great if we could specify a mapping of classes to custom prefixes, or even use the morph map that eloquent already provides.

In addition, the notification type column in the database uses the notification's full class name. This becomes a pain to maintain because the notifications can no longer be moved around the application unless a migration is created to update the paths.

I don't think the type column is actually used anywhere to reconstruct the class, so maybe a type property can be added to the notification class as an override?

public $type = 'invoice-paid';

public function via($notifiable)
{
    return ['broadcast', 'database'];
}
@jlndk
Copy link

jlndk commented Dec 13, 2016

Dont we already have the broadcastAs() function?

@antonkomarev
Copy link

antonkomarev commented Mar 1, 2018

@jlndk it works only for Broadcasting Events, not for notifications.

@fgambino you can define event name since v5.6.4 just return custom event name in broadcastType method of your notification. It was implemented in PR laravel/framework#23236

This issue as well as related #202 could be closed since all the questions which were raised here are solved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants