NovinkaZverejnili sme 50+ Laravel balíkov ako open source
Custom AI apps, agents and automation — Roundly ConsultingRoundly
Všetky balíky
Notifications for Laravel

Fasáda Notifications

Všetko ide cez jednu fasádu, RoundlyConsulting\Notifications\Facades\Notifications, ktorá je skratkou nad singletonom NotificationsManager. Globálny alias neexistuje — od fasády Notification z Laravelu ju delí jedno písmeno — preto ju vždy importujte:

use RoundlyConsulting\Notifications\Facades\Notifications;   // no global alias — always import it

// Types — registered once, read for a settings screen
Notifications::define('comment.posted')->category('comments')->window('PT10M')->register();
Notifications::types()->all();

// Send — flat, fluent, or about one subject
Notifications::send('request.awaiting_approval', $request, $approvers, ['reference' => 'PR-9']);
Notifications::type('request.awaiting_approval')->about($request)->to($approvers)->once("request:{$request->id}")->send();
Notifications::for($contract)->send('contract.expiring', Recipients::owner());

// One recipient's inbox and preferences
Notifications::inbox($user)->in($company)->unread()->paginate();
Notifications::preferences($user)->mute('comment.posted');

// One subject's reminders, acknowledgement and revocation
Notifications::for($task)->remind('task.due', Reminder::before('deadline', 'PT1H'), to: $task->assignee);
Notifications::for($contract)->acknowledge('contract.expiring', by: $user);
Notifications::for($request)->revoke($formerMember);

// The time-driven work the scheduler runs
Notifications::sweep();
Notifications::prune();

Metódy manažéra

MetódaVraciaČo robí
send($type, $subject, $recipients, $data = [], $actor = null, $context = null, $idempotencyKey = null)SendResultUpozorní príjemcov na jednu udalosť — schránka, e-mail, preferencie, deduplikácia, tiché hodiny, súhrny a prístup pre každého príjemcu.
sendNotification(SendNotificationData $data)SendResultOdoslanie ako DTO — používa ho builder aj samotná akcia.
type($type)PendingNotificationFluentné odoslanie: about, to, by, with, in, once, escalate, send.
for(Model $subject)SubjectHandleVšetko o jednom subjekte: odoslania, pripomienky, potvrdenie, odobratie.
inbox(Model $recipient)InboxHandleSchránka jedného príjemcu — nemenné filtre, čítanie, počty, zmeny.
preferences(Model $recipient)PreferencesHandlePreferencie jedného používateľa: kanály, kategórie, súhrn, tiché hodiny a časové pásmo.
register(string ...$types) / registerType(NotificationType $type)voidZaregistruje druhy podľa triedy alebo inštanciu druhu.
define(string $key)TypeBuilderDruh bez triedy.
types()TypesAccessorall(), categories(), find(), has(), get() — pre obrazovku nastavení.
reminders()RemindersAccessorfireDue(), backfill($type), acknowledge($subject, $type, $by).
digests()DigestsAccessorsendDue(), preview($user).
deliveries()DeliveriesAccessordispatchDue().
interop()InteropAccessormap(), suppress(), mapped(), suppressed().
inboxMessage(Model $recipient, InboxMessage $message)?InboxItemZapíše správu kanála inbox z Laravelu do schránky príjemcu.
sweep(?array $only = null)SweepReportSplatné e-maily, súhrny, pripomienky, eskalácie, zastarané prevzatia.
prune()PruneReportZmaže staré riadky (pozrite Príkazy).
Notifications::fake()NotificationsFakeLen na fasáde — fake, ktorý len zaznamenáva (pozrite Testovanie).

perform() a applyInterop() sú na manažéri verejné, ale interné: perform() je jediný kanál, cez ktorý každý handle, builder, kanál aj trait modelu spúšťa svoju akciu — a háčik, cez ktorý fake zaznamenáva — a applyInterop() volá interop listener. Z kódu aplikácie ich nevolajte.

Notifications::for($subject)

MetódaVraciaČo robí
send($type, $recipients, $data = [], $actor = null, $context = null, $idempotencyKey = null)SendResultOdoslanie o tomto subjekte.
type($type)PendingNotificationFluentné odoslanie s vyplneným subjektom.
remind($type, ReminderRule $rule, $to, array $data = [])list<NotificationReminder>Jednorazová pripomienka.
reminders()SubjectRemindersschedule($type, $to), sync(?$type), cancel(?$type), pending(?$type), all(?$type).
acknowledge(?string $type = null, ?Model $by = null)intPotvrdí otvorené pripomienky subjektu a zastaví ich eskalácie.
revoke(?Model $recipient = null)intOdstráni položky príjemcu (alebo všetkých) o subjekte a zruší ich čakajúce e-maily.
subject()ModelSubjekt.

Notifications::inbox($recipient)

Handly sú nemenné — každý filter vráti kópiu:

MetódaVraciaČo robí
unread() / read() / archived() / withArchived()InboxHandleFiltre stavu; predvolene aktívne (nearchivované).
in(Model|string $context) / withoutContext() / allContexts()InboxHandleJeden kontext (model alebo kľúč ako company:3), len položky bez kontextu, alebo všetky kontexty (predvolené).
category($category) / type($type) / since(CarbonInterface)InboxHandleZúži podľa kategórie, druhu alebo nedávnej aktivity.
latest()InboxHandleNajnovšia aktivita prvá — predvolené poradie.
paginate(?int $perPage) / cursorPaginate(?int $perPage)LengthAwarePaginator / CursorPaginatorStránky s eager-loadingom aktérov a subjektov; perPage obmedzené na inbox.max_per_page.
get(?int $limit) / first()Collection / ?InboxItemObmedzený zoznam; najnovšia položka.
find($item)InboxItemPodľa modelu alebo id, len v tejto schránke — inak vyhodí InboxItemNotFoundException.
unreadCount() / counts()int / InboxCountsPočet neprečítaných; neprečítané, celkom a počty pre každý kontext.
markRead($item) / markUnread($item)InboxHandleStav prečítania; markRead() potvrdí aj pripomienku s acknowledgedOnRead().
markAllRead(in: null, category: null)intJeden UPDATE v rámci všetkých filtrov handle; výslovný argument nahradí filter rovnakého druhu.
archive($item) / unarchive($item) / delete($item)InboxHandleArchivuje, vráti z archívu, soft-delete.
recipient()ModelVlastník schránky.

Notifications::preferences($user)

MetódaVraciaČo robí
mute($type, ?Channel $channel = null)PreferencesHandleLen e-mail — alebo každý stlmiteľný kanál pri zapnutom stlmovaní schránky, alebo jeden kanál.
unmute($type, ?Channel $channel = null)PreferencesHandleZruší prepis: návrat k predvolenému nastaveniu kategórie a druhu.
set($type, Channel $channel, bool $enabled)PreferencesHandleVýslovné zapnutie alebo vypnutie.
muteCategory($category, ?Channel) / unmuteCategory($category, ?Channel)PreferencesHandleCelá kategória; nepoužitá kategória vyhodí výnimku.
digest(DigestFrequency $frequency, ?string $time = null)PreferencesHandleOff, daily alebo weekly, voliteľne v miestnom čase.
quietHours(?string $start, ?string $end = null)PreferencesHandleMiestny HH:MM; null ich zruší.
timezone(?string $timezone)PreferencesHandleIANA id; null ho zruší.
update(PreferencesUpdate $update)PreferencesHandleViac zmien naraz, všetky alebo žiadna.
reset()PreferencesHandleZabudne všetky prepisy druhov a kategórií (súhrn, tiché hodiny a časové pásmo zostanú).
matrix() / overview()list<PreferenceRow> / PreferencesOverviewDáta pre obrazovku nastavení, preložené.
enabled($type, Channel) / muted($type)boolVýsledný stav kanála; či je e-mail vypnutý.
digestPreference() / quietHoursPreference() / resolvedTimezone()DigestPreferenceData / ?QuietHours / stringVýsledný súhrn, tiché hodiny a časové pásmo.
user()ModelPoužívateľ.

Buildery, DTO a enumy

  • Buildery: PendingNotification (about, to, by, with, in, once, escalate, data, send), TypeBuilder (pozrite Druhy notifikácií), pravidlá pripomienok Reminder, ReminderRule a EscalationRule a Context (of, key).
  • DTO (final readonly): SendNotificationData, SendResult, RecipientOutcome, TypeDefinition, CategoryDefinition, PreferenceRow, ChannelPreference, PreferencesOverview, PreferencesUpdate, DigestPreferenceData, QuietHours, InboxCounts, ContextCount, ContextReference, ReminderReference, SweepReport, PruneReport, FiredReminders.
  • Enumy: Channel (inbox, mail), Priority (low, normal, urgent), DigestFrequency (off, daily, weekly), MailStrategy (leading, trailing), DeliveryStatus, DigestRunStatus, ReminderStatus (pending, firing, sent, cancelled, skipped), ReminderKind, InboxOutcome, MailOutcome, CancelReason a NotificationOperation. Tie, ktoré vidí používateľ, majú preložené popisy.

Prejavte lásku k open source

Tento balík je zadarmo pod licenciou MIT. Ak vám šetrí čas, jednorazový príspevok alebo členstvo na Patreone nám pomôže ho ďalej udržiavať, testovať a dokumentovať.

Ďalšie spôsoby podpory vrátane kryptomien

Odoslaním daru súhlasíte s našimi podmienkami prijímania darov.

Chcete to zabudovať do svojho produktu?

Naše balíky integrujeme do zákazkových Laravel a AI riešení. Napíšte nám, na čom pracujete, a ozveme sa do 48 hodín.