Download the PHP package juzaweb/notification without Composer
On this page you can find all versions of the php package juzaweb/notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juzaweb/notification
More information about juzaweb/notification
Files in juzaweb/notification
Package notification
Short Description Notification plugin for Juzaweb cms
License MIT
Homepage https://juzaweb.com
Informations about the package notification
Juzaweb CMS Notification Module
This package provides notification management functionality with support for registering and managing different recipient types and notification channels.
Features
- Singleton
NotificationManagerservice for managing recipient types and notification channels - Facade for easy access
- Register custom recipient types and channels with callback pattern
- Query registered recipient types and channels
Installation
The package is auto-registered via Laravel's service provider discovery.
Usage
Registering Notification Channels
You can register notification channels in your service provider's boot() method:
Registering Recipient Types
You can register recipient types in your service provider's boot() method:
Creating Custom Recipient Types
You can create your own custom recipient type classes by implementing RecipientTypeInterface:
Creating Custom Notification Channels
Create notification channels by implementing NotificationChannelInterface:
Getting Recipient Types
Getting Notification Channels
Using in Views
In your controller:
In your Blade view:
Subscriptable Channels
Mark channels as subscriptable to allow users to subscribe/unsubscribe:
Sending Bulk Notifications
Use the SendNotificationJob to send notifications to multiple recipients:
The job will:
- Get recipients from the registered recipient type
- Process recipients in chunks to avoid memory issues
- Send notifications via specified channels
- Update the
sent_attimestamp when complete
Bulk Actions in Admin Panel
From the admin panel, you can select multiple notifications and perform bulk actions:
- Delete: Remove selected notifications
- Send: Queue selected notifications for sending
API Reference
NotificationManager Methods
registerRecipientType(string $key, callable $callback): self
Register a new recipient type.
Parameters:
$key- The unique key for the recipient type$callback- Callback that returns aRecipientTypeInterfaceinstance
Returns: self for method chaining
Example:
registerChannel(string $key, callable $callback): self
Register a new notification channel.
Parameters:
$key- The unique key for the channel$callback- Callback that returns aNotificationChannelInterfaceinstance
Returns: self for method chaining
Example:
getRecipientTypes(): array<string, RecipientTypeInterface>
Get all registered recipient types as objects.
Returns: Array of RecipientTypeInterface objects indexed by key
getRecipientTypesArray(): array<string, array>
Get all registered recipient types as arrays (useful for views).
Returns: Array of arrays with label and description for each type
getRecipientType(string $key): ?RecipientTypeInterface
Get a specific recipient type by key.
Parameters:
$key- The recipient type key
Returns: RecipientTypeInterface object or null if not found
hasRecipientType(string $key): bool
Check if a recipient type is registered.
Parameters:
$key- The recipient type key
Returns: true if exists, false otherwise
unregisterRecipientType(string $key): self
Remove a recipient type.
Parameters:
$key- The recipient type key to remove
Returns: self for method chaining
getChannels(): array<string, NotificationChannelInterface>
Get all registered channels as objects.
Returns: Array of NotificationChannelInterface objects indexed by key
getChannelsArray(): array<string, array>
Get all registered channels as arrays (useful for views).
Returns: Array of arrays with label and description for each channel
hasChannel(string $key): bool
Check if a channel is registered.
Parameters:
$key- The channel key
Returns: true if exists, false otherwise
unregisterChannel(string $key): self
Remove a channel.
Parameters:
$key- The channel key to remove
Returns: self for method chaining
subscriptable(string $channel, array $data = []): void
Mark a channel as subscriptable, allowing users to subscribe or unsubscribe.
Parameters:
$channel- The channel key$data- Optional configuration data (e.g.,['can_unsubscribe' => true])
Example:
getSubscriptableChannels(): array<string>
Get all channels marked as subscriptable.
Returns: Array of channel keys that are subscriptable
Example:
getSubscriptableData(string $channel): array<string, mixed>
Get the subscriptable configuration data for a specific channel.
Parameters:
$channel- The channel key
Returns: Array of configuration data for the channel, or empty array if not found
Example:
RecipientTypeInterface
Interface that all recipient type classes must implement.
getLabel(): string
Get the display label for the recipient type.
getDescription(): ?string
Get the description for the recipient type (optional).
toArray(): array
Convert the recipient type to an array representation.
Returns: Array with label and description keys
getRecipients(): \Illuminate\Database\Eloquent\Builder
Get the Eloquent query builder for fetching recipients.
Returns: Eloquent Builder instance that can be used to fetch recipients
Example:
NotificationChannelInterface
Interface that all notification channel classes must implement.
getLabel(): string
Get the display label for the notification channel.
getDescription(): ?string
Get the description for the notification channel (optional).
toArray(): array
Convert the notification channel to an array representation.
Returns: Array with label and description keys
Examples
Complete Recipient Type Implementation
Sending Notifications with Error Handling
Unregistering Types and Channels
License
Same as the main application license.