Grace
Grace

Reputation: 299

is it possible to notify all users using Laravel notification with pusher?

Is it possible to create/send notification(s) to all users when there is new announcement.

I want all users to be notified using the database notification.

Since most of the tutorials I have seen are all email notification, is this possible? Please attach links or any idea on how I could implement this.

Upvotes: 1

Views: 2183

Answers (1)

Jerodev
Jerodev

Reputation: 33186

Literally in the documentation:

Alternatively, you may send notifications via the Notification facade. This is useful primarily when you need to send a notification to multiple notifiable entities such as a collection of users. To send notifications using the facade, pass all of the notifiable entities and the notification instance to the send method:

Notification::send($users, new InvoicePaid($invoice));

So yes, you can send to all user by getting them from the database and sending a notification using the facade.

For example:

Notification::send(User::all(), new InvoicePaid($invoice));

Upvotes: 4

Related Questions