Skip to content

BaseNotify

Fomvasss\NotifyTemplates\Notifications\BaseNotify — abstract, extends Illuminate\Notifications\Notification.

PropertyTypeDescription
$roleKeystring (protected, no default)Role whose subscription and templates apply. Must be set before sending
$tenantId?string (protected)Tenant; null = config('notify-templates.tenant_id')
$onlyChannels, $exceptChannelsarray (protected)Set by only() / except()
MethodDescription
typeDefinition(): arrayType metadata, see typeDefinition() keys. Default [] — such a class is not registered by discovery
notifyKey(): stringType key used at send time. Default: class name without the trailing Notify
MethodReturnsDescription
only(array $channels)staticKeep only these channels of the resolved ones
except(array $channels)staticRemove these channels from the resolved ones
via(mixed $notifiable)arrayChannel resolution, see Channel resolution
toMail(mixed $notifiable)MailMessageSubject and body of the mail slot through prepareText(); body as plain text — a blank line starts a paragraph (one line() each), a line break becomes <br>, HTML is escaped
toArray(mixed $notifiable)array['message' => strip_tags(getMessengerBody())] for database / broadcast
getNotifyKey()stringstatic::notifyKey()
getRoleKey()?string$roleKey, or null when not set
getTenantId()?string$tenantId as set on the instance (without the config fallback)
getSubjectDefault()stringtypeDefinition()['defaults']['mail']['subject'] or ''
getBodyDefault()stringtypeDefinition()['defaults']['mail']['body'] or ''
MethodReturnsDescription
prepareText(string $text, mixed $notifiable)stringToken substitution hook. Default: returns $text unchanged
mapChannel(string $channel, mixed $notifiable)?stringSlug → Laravel channel, or null to drop. Built-in: mail when the notifiable has a mail route (routeNotificationFor('mail'), else $notifiable->email), database, broadcast. See Custom channels
resolveTemplate(string $channel)?NotifyTemplateTemplate row for a slot with this notification’s key, role and tenant
getMessengerBody(mixed $notifiable, string $slot = 'messenger')string$slot row with a body → messenger slot → mail slot → defaults.mail.body, through prepareText(); see per-channel text
getMessengerButtons(mixed $notifiable, string $slot = 'messenger')array[['text' => string, 'url' => string], ...] — localized, through prepareText(), unsendable urls dropped
getMessengerButtonsColumns(string $slot = 'messenger')intButtons per row
isSendableButtonUrl(string $url)boolAbsolute http(s) url whose host has a dot and doesn’t end in .test, .local, .localhost
manager()NotifyTemplatesManagerThe singleton

getMessengerButtons() and getMessengerButtonsColumns() use the class’s own static::typeDefinition(), not the registry, so buttons work even for a type that isn’t registered.