Class
Opscale\NotificationCenter\Models\Profile
Extends Illuminate\Database\Eloquent\Model. Uses HasPushSubscriptions, HasTags, HasUlids, Notifiable, SoftDeletes, and ValidatorTrait.
Database table: notification_center_profiles
Overview
AProfile is the Notification Center’s internal representation of a notifiable user. Rather than sending notifications directly to your application’s User model, the package dispatches them through Profile records. Each Profile is linked to your application’s notifiable model (e.g. User) via a polymorphic notifiable relationship.
Because Profile uses Laravel’s Notifiable trait, it can be passed directly to Notification::send() or used as the target in any standard Laravel notification dispatch.
Attributes
ULID primary key, auto-generated on creation.
The fully-qualified class name of the polymorphic notifiable model (e.g.
App\Models\User). Part of the ulidMorphs pair.The ULID of the linked notifiable model instance. Part of the
ulidMorphs pair.Timestamp of when the profile was created.
Timestamp of the last update.
Soft-delete timestamp. Present when the profile has been soft-deleted.
Channel-specific contact details (email address, phone number, push endpoint, etc.) are stored on
Subscription records associated with the profile, not on the Profile itself.Eager-loaded relationships
The$with property is set to ['notifiable', 'subscriptions'], so these two relationships are always loaded with every Profile query.
Relationships
notifiable
ReturnsMorphTo — the underlying application model (e.g. a User) that this profile represents.
subscriptions
ReturnsHasMany — the Subscription records associated with this profile. Each subscription represents a verified contact point for a specific channel.
deliveries
ReturnsHasMany — all Delivery records for notifications sent to this profile.
audiences
ReturnsBelongsToMany — the Audience groups this profile belongs to, via the notification_center_audience_profile pivot table.
Key methods
routeNotificationFor($driver, $notification = null)
Overrides the default Laravel routing logic. When the notification implements getSubscription(), that value is returned directly (used for webpush channel routing). Otherwise, it delegates to the parent Notifiable implementation.
The notification channel driver name (e.g.
'mail', 'webpush').The notification instance being dispatched. If it exposes a
getSubscription() method, that subscription is used as the routing target.Tags (via spatie/laravel-tags)
Profile includes the HasTags trait from spatie/laravel-tags. Tags are used by Segment audiences to dynamically select profiles.
Usage examples
Creating a profile for a user
Dispatching a notification to a profile
Looking up a profile from a user
Because
notifiable and subscriptions are always eager-loaded, querying large sets of profiles without additional constraints may result in significant memory usage. Apply without('notifiable', 'subscriptions') if you need a lightweight query.