godforhire/databasenotifications

Database notifications driver for Laravel 5.3 and up
89 2
Install
composer require godforhire/databasenotifications
Latest Version:1.0.2
PHP:>=5.6.4
Laravel:6
Older releases:5
License:MIT
Last Updated:Sep 14, 2019
Links: GitHub  ·  Packagist
Maintainer: godforhire

Database Notification Channel for Laravel 6

Latest Version on Packagist Software License Total Downloads

This package makes it easy to send database notifications with Laravel 6 and up from third-party packages. Those often allow you to send mail or slack notifications, but with this package you can also send them to the notification table. For others, simply use Laravel's own notifications.

Contents

Installation

You can install the package via composer:

composer require godforhire/databasenotifications

Usage

Now you can use the channel in your via() method inside the notification:

use godforhire\DatabaseNotifications\DatabaseChannel;
use godforhire\DatabaseNotifications\DatabaseMessage;
use Illuminate\Notifications\Notification;

class BackupHasFailed extends Notification
{
    public function via($notifiable)
    {
        return [DatabaseChannel::class];
    }

    public function toDatabase($notifiable)
    {
        return DatabaseMessage::create()
                    ->user(1)
                    ->data([
                        'event' => 'Backup failed',
                    	'description' => 'Daily backup of Your App has failed: reason, disk S3 is unreachable.',
                    	'...' => '...'
                    ]);
    }
}

Available Message methods

  • user The user to send the notification to.
  • data An array with custom fields. This can contain any key value pair you want.

License

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

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

644,549,754 9,698
laravel/framework

The Laravel Framework.

598,760,099 34,966
laravel/tinker

Powerful REPL for the Laravel framework.

507,193,856 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

423,477,751 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

403,217,078 4,664

Version History

Version Released PHP Laravel License
1.0.2 >=5.6.4 ^6.0 MIT
v1.0.1 >=5.6.4 ^5.3 MIT
v1.0.0 >=5.6.4 ^5.3 MIT