Storage and persistence
The default store is EloquentNotificationPreferenceStore. It requires a persisted Eloquent model as the notifiable and identifies it with its morph class and primary key.
The migration creates these fields:
notifiable_typeandnotifiable_ididentify the recipient.notification_keyandchannelidentify the preference.context_keystores an empty string for global preferences or a context key such asteam:12.enabledstores the explicit boolean value.
The unique index prevents duplicate values for the same recipient, notification, channel, and context. Bind MutableNotificationPreferenceStore to another implementation when your application uses a different persistence layer.
Context preference store
EloquentNotificationContextPreferenceStore stores policies that belong to a context rather than a notifiable. Its table contains context_key, notification_key, channel, enabled, and mode, with a unique index across the context, notification, and channel fields. Use NotificationContextPreferenceManager for application-level policy operations; the store remains the persistence abstraction behind that manager.
use NotificationCompass\Managers\NotificationContextPreferenceManager;
use NotificationCompass\ValueObjects\NotificationContext;
$administrator = auth()->user();
app(NotificationContextPreferenceManager::class)->disable(
$administrator,
new NotificationContext('team', $teamId),
'incident.created',
'mail',
);
The default table is notificationcompass_context_preferences. Change notificationcompass.context_table before migrating when the application uses another table name. Bind MutableNotificationContextPreferenceStore to replace the Eloquent implementation.
Resolved preference cache
The resolved preference cache is enabled by default. Configure it when preference decisions are evaluated frequently during notification delivery:
'cache' => [
'enabled' => true,
'store' => null,
'ttl' => 300,
'prefix' => 'notificationcompass:preferences',
],
The cache is backend-agnostic and uses the Laravel cache repository selected by cache.store. When cache.store is null, Laravel's cache.default store is used. Preference writes invalidate the relevant notifiable or context version, so stale resolved decisions are not reused after a policy change.