Skip to content

tomatophp/filament-alerts

Repository files navigation

Screenshot

Filament Alerts Sender

Latest Stable Version PHP Version Require License Downloads

Send notification to users using notification templates and multi notification channels

Screenshots

Screenshot Screenshot Screenshot Screenshot

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

  • Email
  • 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.

About

Send notification to users using notification templates and multi notification channels

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages