Database Notifications

Easily manage Laravel Database Notifications for every user in your application.

Admin Interface

Before going deeper, you should know that there's already a section in the admin from where you can manage all your users' notifications.

You can find the notifications section inside Admin -> Access Control -> Notifications.
Feel free to explore all available options this section offers.

Notifications List

Concepts

How Notifications Work

The notifications section inside the admin panel is just a place from where an admin user can manage Laravel Database Notifications.

The platform doesn't come with any extra logic for database notifications, it just offers an admin section from where to manage them.

Please note that when working with database notifications, you are no more required to follow the Laravel Prerequisites section, as the notifications table would've already been created if you've installed the platform correctly.

Admin Operations

As you've probably noticed, inside the admin section for managing notifications, you also have a few available operations, such as: mark notification(s) as read or delete notification(s).

The admin notification operations are only available when you're viewing your own notifications. Your user will have to be selected in the "Belonging To" filter section.

Actionable Notifications

Through the admin operations available for notifications, you might've noticed there's also an individual button for each notification called "Action".

When clicking this button, the following will happen:

Usage

Delete Old Notifications

There are two ways to delete old errors:

Either of these options are fine, but they're still manual. It's recommended to schedule the varbox:clean-notifications command to run periodically, inside your App\Console\Kernel class.

/**
 * Define the application's command schedule.
 *
 * @param \Illuminate\Console\Scheduling\Schedule $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('varbox:clean-notifications')->monthly();
}

The way to determine what notifications are old, is by using the old_threshold key from inside the config/varbox/notifications.php config file, so feel free to modify that value.

/*
|
| This option accepts an integer, representing the number of days.
|
| Delete notification records older than the number of days supplied when:
| - executing the cli command: "php artisan varbox:clean-notifications"
| - clicking the "Delete Old Notifications" button from the admin panel
|
| If set to "null" or "0", no past notifications will be deleted whatsoever.
|
*/
'old_threshold' => 30,

Configuration

The notifications configuration file is located at config/varbox/notifications.php.
For more information on how you can customize the functionality, read the comments from that file.

Overwrite Bindings

In your projects, you may stumble upon the need to modify the behavior of these classes, in order to fit your needs. Varbox makes this possible via the config/varbox/bindings.php configuration file. In that file, you'll find every customizable class the platform uses.

For more information on how the class binding works, please refer to the Custom Bindings documentation section.

Varbox\Controllers\NotificationsController

Found in config/varbox/bindings.php at controllers.notifications_controller key.
This class is used for interactions with the "Admin -> Access Control -> Notifications" section.

Varbox\Composers\NotificationsComposer

Found in config/varbox/bindings.php at view_composers.notifications_view_composer key.
The view composer for the notification icon in the header.