Notification class abstract
A notification (Laravel's Notification): via names the channels,
and each channel reads its own method.
final class InvoicePaid extends Notification {
InvoicePaid(this.invoice);
final Invoice invoice;
@override
List<String> via(Object notifiable) => ['mail', 'database'];
@override
NotificationMail toMail(Object notifiable) => NotificationMail()
.subject('Invoice paid')
.line('We received your payment of ${invoice.total}.')
.action('View invoice', 'https://example.com/invoices/${invoice.id}');
@override
Map<String, Object?> toDatabase(Object notifiable) =>
{'invoice_id': invoice.id, 'total': invoice.total};
}
await user.notify(InvoicePaid(invoice));
Constructors
- Notification()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
broadcastAs(
) → String -
The broadcast event name: Laravel's
Illuminate\Notifications\Events\BroadcastNotificationCreated. -
broadcastOn(
Object notifiable) → List< String> -
The channels to broadcast on; empty for the notifiable's own
(
private-App.Models.User.1, Laravel'sreceivesBroadcastNotificationsOnas aPrivateChannel). -
broadcastType(
Object notifiable) → String -
The
typesent with a broadcast: databaseType by default. -
databaseType(
Object notifiable) → String -
The
typecolumn: Laravel stores the notification's class name, so the default isApp\Notifications\<ClassName>. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toArray(
Object notifiable) → Map< String, Object?> -
toBroadcast(
Object notifiable) → Map< String, Object?> ? -
For the
broadcastchannel: the data sent; toArray when null (Laravel'stoBroadcast). -
toDatabase(
Object notifiable) → Map< String, Object?> ? -
For the
databasechannel: thedatacolumn; toArray when null. -
toMail(
Object notifiable) → Object? -
For the
mailchannel: a NotificationMail or a Mailable. -
toString(
) → String -
A string representation of this object.
inherited
-
via(
Object notifiable) → List< String> -
The channels to send on:
mail,database, or a registered one.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited