fantismic / alert-system
Reusable Laravel alerting system
Installs: 93
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: ^8.1
- illuminate/support: ^11.0
- dev-main
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.6
- v1.6.5
- v1.6.4
- v1.6.3
- v1.6.2
- v1.6.1
- v1.6.0
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.5
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
This package is auto-updated.
Last update: 2025-07-13 06:37:54 UTC
README
A reusable Laravel package to send alerts via multiple channels (e.g., mail, telegram) based on alert type and channel combinations โ stored in the database for easy admin management.
โจ Features
- Alert types like
System
,User
(customizable) - Channel support:
mail
,telegram
,discord
(more to come) - Dynamically manage recipients from the database
- Supports Laravel Notifications and queues
- Uses a Facade:
Alert::send(...)
- Includes an optional dashboard with filters and search
- Logs each alert sent per recipient and status
โ Requirements
Mandatory
- Laravel >= 11
- PHP >= 8.1
- Database migrations
Optional
- Tailwind CSS (for UI)
- Livewire (for UI)
๐ท Screenshots
Light mode
Dark mode
Telegram
๐ฆ Installation
composer require fantismic/alert-system
Publish migrations
php artisan vendor:publish --tag=alert-system-migrations php artisan migrate
Publish configuration:
php artisan vendor:publish --tag=alert-system-config
You can define:
- Which Blade layout to use for the Livewire UI
- Which environments (
envs
) are allowed to send alerts- Set telegram token
- Set telegram proxy
- Set global cooldown
You can set as many telegram bots as you like here, or leave only one and use different addresses to different groups for the same bot.
Publish seeders (optional):
php artisan vendor:publish --tag=alert-system-seeders php artisan db:seed --class=AlertTypesTableSeeder php artisan db:seed --class=AlertChannelsTableSeeder
๐ Tables
This package creates the following tables:
alert_types
alert_channels
alert_recipients
alert_logs
Example:
Type | Channel | Address |
---|---|---|
System | admin@example.com | |
System | telegram | @sysadmin_channel |
๐ Usage
use Fantismic\AlertSystem\Facades\Alert; Alert::send('Healthcheck', '๐ฅ CPU is on fire');
use Fantismic\AlertSystem\Facades\Alert; Alert::send('System', 'The disk is almost full', [ 'host' => 'web-01', 'threshold' => '95%', ], [ 'mailSubject' => '๐จ Disk Alert', 'cooldown' => 0, ]);
This will:
- Look up all recipients for the given type
- Send via all associated channels (mail, telegram)
- Log success/failure per recipient
๐ง Signature
Alert::send( string $type, string $message, array $details = [], array $options = [] // mailSubject, cooldown ): void
๐ ๏ธ Customization
Email Templates
After publishing the views:
php artisan vendor:publish --tag=alert-system-views
You'll find the default template at:
resources/views/vendor/alert-system/mail/error_alerts/default.blade.php
Use Blade logic to customize per type (e.g., error_alerts.system.blade.php
).
๐ฅ๏ธ Admin UI
๐ Routes
Path | Route Name |
---|---|
/admin/alerts/dashboard | alerts.dashboard |
/admin/alerts/types | alerts.types |
/admin/alerts/channels | alerts.channels |
/admin/alerts/recipients | alerts.recipients |
Uses web
and auth
middleware by default.
๐ก Features
- Create, edit, delete alert types, channels, and recipients
- View alert logs in a searchable, filterable table
- Filter by status (success/failure), type, channel
- View alert detail in a modal
- Export alert logs to CSV
- Dark mode support
๐ Logs
Each time an alert is sent, a log is created in the alert_logs
table.
๐งพ Columns
Column | Description |
---|---|
id | Primary key |
type | Alert type name |
channel | Channel name (mail/telegram) |
address | Recipient address |
bot | Bot (if applicable) |
subject | Subject used |
message | Message used |
details | JSON-encoded extra details |
status | success or failure |
error_message | Error if status is failure |
sent_at | Timestamp |
created_at | Timestamp |
updated_at | Timestamp |
๐งฑ Model
You can use the model directly for custom dashboards:
use Fantismic\AlertSystem\Models\AlertLog; $recent = AlertLog::latest()->take(10)->get();
โ License
MIT ยฉ Fantismic