john-wink/jw-notifications

Filament Plugin for customizable Notification Channels per User

1.0.3 2024-10-31 23:01 UTC

This package is auto-updated.

Last update: 2024-10-31 23:02:28 UTC


README

With this Plugin you can customize the Notifications Channel per User

Installation

You can install the package via composer:

composer require john-wink/jw-notifications

You can publish and run the migrations with:

php artisan vendor:publish --tag="jw-notifications-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="jw-notifications-config"

Optionally, you can publish the views using

php artisan vendor:publish --tag="jw-notifications-views"

This is the contents of the published config file:

return [
    'table'      => 'subscribed_channels',
    'notifiable' => App\Models\User::class,
];

Usage

Replace the via() function within Notifications that you want to use with this trait:

    use \JohnWink\JwNotifications\Traits\HasCustomizedChannels;

Add the following trait to the user:

    use \JohnWink\JwNotifications\Traits\CanSubscribeToChannels;

Configure the FilamentPanels according to this example: Replace the notifications with your own notifications and the channels with your own channels that you have installed and configured.

return $panel->plugins([
    JwNotificationsPlugin::make()
        ->notifications([
            /*
            * Add here your Notifications Channels
            * The Notification Channel should use the Trait: 
            * \JohnWink\JwNotifications\Traits\HasCustomizedChannels
            */
        ])
        ->channels(fn () => [
            'database'        => 'Database',
            'mail'            => 'Email',
        ]),
    ]);

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.