Repository navigation
Add the database notification channel - #396
Open
turgutahmet wants to merge 1 commit into
Open
turgutahmet wants to merge 1 commit into
turgutahmet wants to merge 1 commit into
Conversation
A `database` method in a `#[notification]` impl stores the notification in the `notifications` table for every model it's sent to. Models read their notifications back with `DatabaseNotification::of`, and mark them as read or unread one at a time or all at once. `laravel::notification::table!()` creates the table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#178 left the database notification channel for later, so there's no built-in way to keep notifications around for an in-app list (the usual bell icon with unread notifications).
Change
#[notification]accepts adatabasemethod that returns anySerializevalue. It's stored with the notification's type, the struct name in snake case (invoice_paid):Databasechannel is built with#[notification::channel], likeSlack, so queueing,channels, transactions, and the fake work as they do for other channels.Uuidkeys bind natively, souuid_morphsworks on PostgreSQL.laravel::notification::table!()creates the table, using the same schema as Laravel 13'snotificationsstub.insert_or_ignore, so a retried queued delivery doesn't store it twice.notifications.md, and the new macro inmigrations.md.Tests
tests/notifications_database.rs, with the main contracts also run as ignored tests on PostgreSQL and MySQL. I ran them locally against PostgreSQL 18 and MySQL 8.4.Not included: the broadcast channel, a custom stored type (like
databaseType()), a configurable table, and pruning.