<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
asignua / filament-notification-preferences example snippets
use Asignua\FilamentNotificationPreferences\NotificationPreferencesPlugin;
$panel->plugin(
NotificationPreferencesPlugin::make()
->navigationGroup('Settings')
->userMenu(),
);
use Asignua\FilamentNotificationPreferences\NotificationPreferences;
use Asignua\FilamentNotificationPreferences\Support\NotificationType;
public function boot(): void
{
NotificationPreferences::register(
NotificationType::make(InvoicePaid::class)
->key('billing.invoice-paid') // stable id stored in the database; defaults to the class name
->label(fn () => __('Invoice paid')) // a string or a closure, resolved when the page renders
->description('Sent when a customer pays one of your invoices.')
->group('Billing')
->channels(['mail', 'database', SmsChannel::class => 'SMS'])
->default([SmsChannel::class => false]), // true / false, or per channel (a channel left out stays on)
NotificationType::make(SecurityAlert::class)->group('Security')->locked(),
);
}
NotificationPreferences::for($user)->allows(InvoicePaid::class, 'mail'); // also accepts the key or a notification instance
NotificationPreferences::for($user)->matrix(); // what the user gets now
NotificationPreferences::for($user)->save(['billing.invoice-paid' => ['mail' => false]]);
NotificationPreferences::register(
NotificationType::make(\Asignua\FilamentChat\Notifications\NewMessageNotification::class)->key('chat.message')->label('New chat message')->group('Chat')->channels(['database']),
NotificationType::make(\Asignua\FilamentChat\Notifications\MentionNotification::class)->key('chat.mention')->label('Mentions in chat')->group('Chat')->channels(['database']),
NotificationType::make(\Asignua\FilamentChatPro\Notifications\DigestNotification::class)->key('chat.digest')->label('Chat digest')->group('Chat')->channels(['mail']),
);