### Install the package via Composer Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Run this command in your terminal to add the package to your project. ```bash composer require prodstarter/filament-notification-center ``` -------------------------------- ### Publish the configuration file Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Use this command to publish the package configuration for customization. ```bash php artisan vendor:publish --tag="filament-notification-center-config" ``` -------------------------------- ### Run project tests Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Executes the test suite using Composer. ```bash composer test ``` -------------------------------- ### Configuring import notification settings Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Enable and customize the imports tab settings in the published configuration file. ```php // config/notification-center.php 'imports' => [ 'enabled' => true, 'category' => 'imports', 'label' => 'Imports', 'icon' => 'heroicon-o-arrow-up-tray', 'color' => 'info', 'order' => 90, ], ``` -------------------------------- ### Register the plugin in a panel provider Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Add the plugin to your panel configuration and define categories to replace the default notification drawer. ```php use Filament\\Panel; use Filament\\Support\\Colors\\Color; use Filament\\Support\\Icons\\Heroicon; use Prodstarter\\FilamentNotificationCenter\\FilamentNotificationCenterPlugin; use Prodstarter\\FilamentNotificationCenter\\NotificationCenterCategory; public function panel(Panel $panel): Panel { return $panel // ... ->databaseNotifications() ->plugins([ FilamentNotificationCenterPlugin::make()->categories([ NotificationCenterCategory::make('system') ->label('System') ->icon(Heroicon::Cog6Tooth) ->color(Color::Gray) ->order(1), NotificationCenterCategory::make('orders') ->label('Orders') ->icon(Heroicon::ShoppingBag) ->color(Color::Amber) ->order(2), NotificationCenterCategory::make('crm') ->label('CRM') ->icon(Heroicon::Users) ->color(Color::Blue) ->order(3), NotificationCenterCategory::make('billing') ->label('Billing') ->icon(Heroicon::CreditCard) ->color(Color::Emerald) ->order(4), ]), ]); } ``` -------------------------------- ### Customize default category and empty states Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Configure the default category and provide a custom empty state message. ```php FilamentNotificationCenterPlugin::make() ->categories([...]) ->defaultCategory('general') // where uncategorized notifications land ->emptyStateUsing(fn (string $categoryId): array => [ 'heading' => "Nothing here yet", 'description' => "You're all caught up in {$categoryId}.", ]); ``` -------------------------------- ### Registering global notification categories Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Register categories in a service provider's boot method to share them across all app panels. ```php use NotificationCenter; NotificationCenter::categories([ // ... ]); ``` -------------------------------- ### Default configuration file content Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md The default configuration file defines the category ID for uncategorized notifications. ```php return [ // The category ID that notifications sent without an explicit ->category() // are grouped under in the notification center drawer. 'default_category' => 'general', ]; ``` -------------------------------- ### Categorizing import and export notifications Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Apply the appropriate trait to your Importer or Exporter class to enable automatic notification categorization. ```php use Filament\Actions\Imports\Importer; use Prodstarter\FilamentNotificationCenter\Concerns\CategorizesImportNotifications; class ProductImporter extends Importer { use CategorizesImportNotifications; // ... } ``` ```php use Filament\Actions\Exports\Exporter; use Prodstarter\FilamentNotificationCenter\Concerns\CategorizesExportNotifications; class ProductExporter extends Exporter { use CategorizesExportNotifications; // ... } ``` -------------------------------- ### Use enums for categories Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Register enum-based categories and use them when sending notifications. ```php FilamentNotificationCenterPlugin::make()->categories([ NotificationCategory::Orders, NotificationCategory::Crm, ]); Notification::make() ->title('New order #1042 received') ->category(NotificationCategory::Orders) ->sendToDatabase($user); ``` -------------------------------- ### Send a categorized notification Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Use the category method when sending a notification to assign it to a specific tab. ```php use Filament\\Notifications\\Notification; Notification::make() ->title('New order #1042 received') ->icon('heroicon-o-shopping-bag') ->color('warning') ->category('orders') ->sendToDatabase($user); ``` -------------------------------- ### Customizing categorized notifications Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Use the helper method inside a custom modifyCompletedNotification implementation if you need to override default notification behavior. ```php use Filament\Actions\Imports\Importer; use Filament\Actions\Imports\Models\Import; use Filament\Notifications\Notification; use Prodstarter\FilamentNotificationCenter\Concerns\CategorizesImportNotifications; class ProductImporter extends Importer { use CategorizesImportNotifications; public static function modifyCompletedNotification(Notification $notification, Import $import): Notification { $notification = static::categorizeImportNotification($notification); return $notification->icon('heroicon-o-shopping-bag'); } } ``` -------------------------------- ### Define a category enum Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Implement Filament contracts in an enum to automatically handle labels, icons, and colors for categories. ```php use Filament\\Support\\Contracts\\HasColor; use Filament\\Support\\Contracts\\HasIcon; use Filament\\Support\\Contracts\\HasLabel; enum NotificationCategory: string implements HasColor, HasIcon, HasLabel { case Orders = 'orders'; case Crm = 'crm'; public function getLabel(): string { return match ($this) { self::Orders => 'Orders', self::Crm => 'CRM', }; } public function getIcon(): string { return match ($this) { self::Orders => 'heroicon-o-shopping-bag', self::Crm => 'heroicon-o-users', }; } public function getColor(): string { return match ($this) { self::Orders => 'amber', self::Crm => 'info', }; } } ``` -------------------------------- ### Categorize a Notification Source: https://github.com/prodstarter/filament-notification-center/blob/main/README.md Use the category method within the notification chain to assign a notification to a specific tab. ```php Notification::make()->title(...)->sendToDatabase($user)->category('orders') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.