tomatophp / filament-alerts
Send notification to users using notification templates and multi notification channels
Fund package maintenance!
3x1io
Requires
- php: ^8.1|^8.2
- filament/filament: ^3.0.0
- filament/notifications: ^3.0.0
- filament/spatie-laravel-media-library-plugin: ^3.2
- filament/spatie-laravel-translatable-plugin: ^3.2
- laravel/slack-notification-channel: ^3.2
- tomatophp/console-helpers: ^1.1
- tomatophp/discord-notifications: ^1.0
- tomatophp/fcm-notifications: ^1.0
- tomatophp/filament-settings-hub: ^1.0
- tomatophp/messagebird-notifications: ^1.0
- tomatophp/pusher-notifications: ^1.0
This package is auto-updated.
Last update: 2024-04-16 11:53:26 UTC
README
Filament Alerts Sender
Send notification to users using notification templates and multi notification channels
Screenshots
Installation
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
Usage
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
Queue
the notification is run on queue, so you must run the queue worker to send the notifications
php artisan queue:work
Notification Service
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.
Send 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
Notification Channels
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);
API
we are support some API to get the notification and make some actions you can find it under api/notifications
route
Publish Assets
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"
Support
you can join our discord server to get support TomatoPHP
Docs
you can check docs of this package on Docs
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security
Please see SECURITY for more information about security.
Credits
License
The MIT License (MIT). Please see License File for more information.