Notifications
class Notifications
Utilities that support console commands related to Notifications:
- Resolving notifiables and channels from CLI options
- Building per-send payloads/overrides
- Scaffolding notification classes and the notifications migration
- Performing dry-runs and actual sends via a notifiable
Constants
| NOTIFICATION_NAMESPACE |
|
| NOTIFICATION_PATH |
|
Methods
Build the per-send payload for the test command.
Resolve the --channels option into a normalized list of channels.
Perform a dry-run (no delivery). Prints the intended action and payload.
Generate a new notification class file into {self::NOTIFICATION_PATH}.
Template for the notifications migration class file.
Build a fully-qualified notification class name.
Determine if a notification class exists.
Create a new notifications migration file on disk.
Resolve a notifiable instance (or a sentinel string) from CLI input.
Parse overrides from the --with option (key:value,key2:value2).
Prune old notifications using the model layer.
Resolve a channels override list from CLI input.
Deliver a notification via a notifiable (or simulate if notifiable is not an object).
Details
at line 40
static array
buildPayload(InputInterface $input, array $overrides)
Build the per-send payload for the test command.
Default fields:
- level: "info"
- tags: ["cli","test"]
- dry_run: boolean (from --dry-run)
at line 63
static array
channelOptions(InputInterface $input)
Resolve the --channels option into a normalized list of channels.
Behavior:
- If the option is omitted or empty, returns ALL enum channel values (use {\Console\Helpers\resolveChannelsOverride()} if you prefer NULL to defer to via()).
- Accepts a comma-separated list, whitespace tolerated.
- Accepts the special token "all" to mean all channel enum values.
- Validates unknown names and deduplicates while preserving order.
at line 101
static bool
dryRun(object|string $notifiable, Notification $notification, array $payload, array|null $channels)
Perform a dry-run (no delivery). Prints the intended action and payload.
at line 155
static int
makeNotification(array|null $channels, string $notificationName)
Generate a new notification class file into {self::NOTIFICATION_PATH}.
The generated class includes channel methods (toX) for the provided list, plus a via() that references those channels. If $channels is NULL or empty, all enum channel values are used.
at line 179
static string
migrationTemplate(string $fileName)
Template for the notifications migration class file.
at line 229
static string
notificationClass(string $notificationName)
Build a fully-qualified notification class name.
at line 241
static bool
notificationClassExists(string $className)
Determine if a notification class exists.
at line 250
static int
notificationsMigration()
Create a new notifications migration file on disk.
at line 303
static object|string
resolveNotifiable(InputInterface $input)
Resolve a notifiable instance (or a sentinel string) from CLI input.
at line 318
static array
resolveOverridesFromWith(InputInterface $input)
Parse overrides from the --with option (key:value,key2:value2).
at line 341
static int
prune(int $days)
Prune old notifications using the model layer.
at line 356
static array|null
resolveChannelsOverride(InputInterface $input)
Resolve a channels override list from CLI input.
If the option is omitted/empty, returns NULL so callers can defer to via().
at line 371
static void
sendViaNotifiable(object|string $notifiable, Notification $notification, array $payload, array|null $channels)
Deliver a notification via a notifiable (or simulate if notifiable is not an object).