Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get this working for guests? #61

Open
kirkbushell opened this issue May 21, 2021 · 2 comments
Open

How to get this working for guests? #61

kirkbushell opened this issue May 21, 2021 · 2 comments

Comments

@kirkbushell
Copy link

I've been trying for a couple of hours now to send push messages to guests of our website, but no matter what I do it seems to run afoul of the way Laravel wants to work - that being, using some sort of Notifiable class, such as User.

Anyone have suggestions as to how to make this work?

@geeksalah7
Copy link

Simple, create a class with any name (i.e. Guests) in the App Dir, as below.

<?php
namespace App;

use Illuminate\Notifications\Notifiable;

class Guests{
    use Notifiable;

    public function routeNotificationForPusherPushNotifications() : string{
        return 'guests_users';
    }
}

And then in your controller, repo etc. send the notification as:
Notification::send(new Guests(), new NewInvoice($invoice));

On the client side subscribe your users/devices to the guests_users interest.

@socieboy
Copy link

That works, but what if you want to send also a email?

$users = User::all();
Notification::send($users, new NewVersionRelease($release));

Let's say you want pusher to send it via the "guest" interest, but for mail it needs to send to each individual email address,
also, if the routeNotificationForPusherPushNotifications() return guests_users it will create one push notification for each user to the same interests. i will fail.

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

No branches or pull requests

3 participants