People searching “Laravel notification mail and database” create a mailable and a notification and send both by hand. One notification can list both channels. The notifications guide is the bell. This page is via().
TL;DR
- via() can return mail and database.
- The Vue bell reads the database row.
- It does not read the mailable.
- Do not
Mail::sendandnotifywith two different texts that can drift.
The fix#
public function via(object $notifiable): array
{
return ['mail', 'database'];
}The database channel needs the notifications table:
php artisan notifications:table
php artisan migratetoArray() is what the bell stores. toMail() is the email. Keep the secrets out of both. The Vue page still loads the unread rows the way the notifications guide shows. You do not poll the mailbox.
What to avoid#
Gotcha
Do not Mail::send and notify with two different texts that can drift. Do not put the HTML of the mail into the database column and render it with v-html.
FAQ#
How do I send mail and a database notification?
via() can return mail and database. The Vue bell reads the database row. It does not read the mailable.
What goes wrong with Laravel notification mail and database?
Many developers create a mailable and a notification and send both by hand. Do not Mail::send and notify with two different texts that can drift.



