LaravelPackages.net
Acme Inc.
Toggle sidebar
digitalcloud/reactive-notification

Reactive Laravel Notification

115
16
v1.0
About digitalcloud/reactive-notification

digitalcloud/reactive-notification is a Laravel package for reactive laravel notification. It currently has 16 GitHub stars and 115 downloads on Packagist (latest version v1.0). Install it with composer require digitalcloud/reactive-notification. Discover more Laravel packages by digitalcloud or browse all Laravel packages to compare alternatives.

Last updated

Reactive Laravel Notification

Installation

PHP >=5.6 and Laravel ^5.3 are required.

To get the latest version of Reactive Laravel notification, simply require the project using Composer:

composer require digitalcloud/reactive-notification

publishing migration file

php artisan vendor:publish --provider="Digitalcloud\ReactiveNotification\ReactiveNotificationServiceProvider"

migrate published migration files

php artisan migrate

Usage

  1. Change trait used in model from Illuminate\Notifications\Notifiable to Digitalcloud\ReactiveNotification\Traits\Notifiable
<?php namespace App; use Digitalcloud\ReactiveNotification\Traits\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; }
  1. Change delivery channel from database or DatabaseChannel to Digitalcloud\ReactiveNotification\Channels\DatabaseChannel
<?php namespace App\Notifications; use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Digitalcloud\ReactiveNotification\Channels\DatabaseChannel; class InvoicePaid extends Notification implements ShouldQueue { use Queueable; public function via($notifiable) { return [DatabaseChannel::class,'.../']; } public function toDatabase($notifiable){ return [ "title"=> trans("invoice_title"), "details"=> trans("invoice_details"), ]; } }

Example

$user->notify(new InvoicePaid($invoice)); \App::setLocale("en"); $result = $user->notifications()->first()->data;

the result will be [ "title" => "Invoice title", "details" => "Invoice details" ]

then change the old language from en into ar

\App::setLocale("ar"); $result = $user->notifications()->first()->data;

and the result will be [ "title" => "عنوان الفاتورة", "details" => "تفاصيل الفاتورة" ]

Star History Chart