Send notification to users using notification templates and multi notification channels
before use this package make sure you have installed
composer require tomatophp/filament-alerts
after install your package please run this command
php artisan filament-alerts:install
to set up any model to get notifications you
<?php
namespace App\Models;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Fortify\TwoFactorAuthenticatable;
use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
use TomatoPHP\FilamentAlerts\Traits\InteractsWithNotifications;
class User extends Authenticatable
{
use HasApiTokens;
use HasFactory;
use HasProfilePhoto;
use Notifiable;
use TwoFactorAuthenticatable;
use HasRoles;
use InteractsWithNotifications;
...
and you must set the settings for FCM to get real-time notification
the notification is run on queue, so you must run the queue worker to send the notifications
php artisan queue:work
to create a new template you can use template CRUD and make sure that the template key is unique because you will use it on every single notification.
to send a notification you must use our helper SendNotification::class like
SendNotification::make($template->providers)
->template($template->key)
->findTitle($matchesTitle)
->replaceTitle($titleFill)
->findBody($matchesBody)
->replaceBody($titleBody)
->model(User::class)
->id(User::first()->id)
->privacy('private')
->fire();
where $template
is selected of the template by key and $matchesTitle and $matchesBody is an array of matches to replace the template and $titleFill and $titleBody are an array of values to replace the matches
you can use multiple notification channels like
- SMS
- FCM
- Pusher
- Database
- Slack
- Discord
it can be working with direct user methods like
$user->notifySMSMisr(string $message);
$user->notifyEmail(string $message, ?string $subject = null, ?string $url = null);
$user->notifyFCMSDK(string $message, string $type='web', ?string $title=null, ?string $url=null, ?string $image=null, ?string $icon=null, ?array $data=[]);
$user->notifyPusherSDK(string $token, string $title, string $message);
$user->notifyDB(string $message, ?string $title=null, ?string $url =null);
$user->notifySlack(string $title,string $message=null,?string $url=null, ?string $image=null, ?string $webhook=null);
$user->notifyDiscord(string $title,string $message=null,?string $url=null, ?string $image=null, ?string $webhook=null);
we are support some API to get the notification and make some actions you can find it under api/notifications
route
you can publish config file by use this command
php artisan vendor:publish --tag="filament-alerts-config"
you can publish views file by use this command
php artisan vendor:publish --tag="filament-alerts-views"
you can publish languages file by use this command
php artisan vendor:publish --tag="filament-alerts-lang"
you can publish migrations file by use this command
php artisan vendor:publish --tag="filament-alerts-migrations"
you can join our discord server to get support TomatoPHP
you can check docs of this package on Docs
Please see CHANGELOG for more information on what has changed recently.
Please see SECURITY for more information about security.
The MIT License (MIT). Please see License File for more information.