phplaravellaravel-maillaravel-notification

Laravel Notification or Mailable for friend request/accept


Suppose that we have a social website that users can follow each other. Is it a better idea to use Laravel Notification to notify the user that someone wants to follow him or someone accepted his follow request or Laravel Mailable instead?

I have already read this question and seems that Mailable is a better idea because the recipient and the email content is not the same (in the content I have to say that $thisUserId is requesting to follow you, or $thisUserId accepted your follow request.

What is the best way to implement this (follow request, follow accepted) or other actions such as your friend commented on your post or something like this?

Laravel Notification or Laravel Mailable?


Solution

  • It seems you underestimate the Laravel Notification. It has also fliexibility to use the custom templates. And you can use mailable with this as well.

    Follow the documentation. https://laravel.com/docs/5.8/notifications

    As friend request sent/accept comes under notification category and Laravel Notification just designed for the notificaiton purpose only. So no doubt you should go with this.

    As it's provide the flexibility send notification on different channels as well along with mail.

    The mailable is very limited to provide the reach mailing feature with laravel.

    Rest all depends on your application architecture & your descision :)