FusionCMS is currently in an open beta state and under heavy active development.

Notifications

Notifications can range from registration emails to SMS messages, depending on how you set it up. Notifications can easily be sent with a helper method FusionCMS provides.

Channels

Notifications

As of the writing of this article FusionCMS comes equipped with only the mail channel, however this can be easily expandable. Laravel provides a wealth of Notification Channels and even provides guides on their website.

Subscriptions

FusionCMS makes subscribing to your Notification library easy through the Users module. This allows full control to control which members of your team will recieve what, for example so members may need to be notified when new users are registered for onboarding. The possibilities are endless.

User Notifications

Extending

Channels

Available channels are set in Fusion\Console\Actions\SyncNotifications with the $channels property. As of now only mail is configured, but eventually this will be available to configure through the Control Panel.

If you wish to add more channels, make sure they are first properly configured in your config/services.php or somewhere else.

Finally run php artisan fusion:sync to register the new channel.

For adding additional custom channels read Laravel's documentation article.

Adding Notifications

Notifications are registered whenever fusion:sync is called from the command line. This command will synchronize any Notifications listed in the notifications folder (Addon modules included).

Registration Format

<?php //i.e. notifications/foo.php

return [
    'GroupName' => [
            'Foo Bar Baz' => Fusion\Notifications\FooBarBaz::class,
    ]
];

For organizational purposes, group your Notifications as you feel appropriate. The name you provide will be converted into a handle, which will be used to for reference later. For example, the notification above will be assigned the handle foo_bar_baz.

Notification Class

Next, you'll want to assure the Notification class exists. Read Laravel's documentation for more information on Generating Notifications.

Sending Notification

Notifications

FusionCMS provides a helper method to easily send notifications. All you have to do is provide the notification handle and any arguments you want to pass. The Notification class will then pickup upon these arguments and fire off a notification to anyone subscribed.

notify('{handle}', ...$args);

For example, after a new user has successfully registered the following will

notify('new_user_registration', $user);

How It Works

When using FusionCMS's notify() helper method all subscribers are pulled and thus notified. Furthermore, the Notification class includes a via method to expedite to the requested Channels. This method receives an argument $notifiable (commonly Fusion\Models\User).

class NewUserRegistration extends Notification
{
    public function via($notifiable): array
    {
        return $notifiable->via(__CLASS__);
    }
}

The snippet above shows how FusionCMS will match the $notifiable (aka User) with the channels they've subscribed to. via has been overrided in FusionCMS's own Fusion\Concerns\Notifiable class.

Have questions?

We're always happy to help with code or other questions you might have. Contact support or chat live with us on Discord.

Last edited on Wednesday, March 31, 2021 (3 years ago)