laravelista / comments

Native comments for your Laravel application.
MIT License
745 stars 144 forks source link

Making events for new comment #154

Closed eduardonwa closed 3 years ago

eduardonwa commented 3 years ago

If I want to get an email notification whenever a post gets a new comment should I include the Listener in the vendors/laravelista/comments/ folder, or could I make it inside the App folder and create the listener within the app folder? If you can in fact create the listener right in the app, how should I ask for the CommentCreated.php class event?

eduardonwa commented 3 years ago

Why was the Dispatch trait wasn't included in the CreatedComment? Can I use it? Wouldn't want to break anything.

mabasic commented 3 years ago

See my comment in #137.

TLDR version. You need to create a listener in your app and in EventServiceProvider map the event CommentCreated to your listener.

eduardonwa commented 3 years ago

Like this:

    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        \Laravelista\Comments\Events\CommentCreated::class => [
            SendEmailNewComment::class,
        ],
    ];

?

mabasic commented 3 years ago

That should do it.