Download the PHP package mhd-elawi/notification without Composer
On this page you can find all versions of the php package mhd-elawi/notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mhd-elawi/notification
More information about mhd-elawi/notification
Files in mhd-elawi/notification
Package notification
Short Description A notification package for Laravel
License MIT
Informations about the package notification
Notification Package
Table of Contents
- Introduction
- Features
- Installation
- Install the Package
- Publish Configuration and Migrations
- Run Migrations
-
Configuration
- Default Language
- Supported Languages
-
Save Notifications
- Firebase Configuration
- Usage
- Sending Notifications
-
- Implementing HasNotification
- Disabling Persistence
- Disabling Notification
- Advanced Configuration
- Contributing
Introduction
The Notification Package is a Laravel package designed for managing multi-language notifications with support for:
- Database persistence: Save notifications for future reference.
- Firebase Cloud Messaging (FCM): Send push notifications to mobile devices.
- Multi-language support: Easily translate notification content into multiple languages.
Features
- Multi-language notifications
- Database persistence for auditability
- Integration with Firebase for push notifications
- Batch processing for scalable notifications
- Flexible configuration
Installation
Install the Package
Run the following command:
Publish Configuration and Migrations
Publish Configuration File
Publishes the configuration file to config/notification.php.
Publish Migrations
Publishes the migration files to database/migrations.
Run Migrations
Run the migrations:
Configuration
Default Language
Set the default language for notifications:
If a language is not specified for a notification, it will fall back to this language.
Supported Languages
Define the list of supported languages:
Save Notifications
By default, notifications are saved to the database:
Firebase Configuration
Firebase configuration is optional. If using Firebase, configure the following:
Firebase Credentials
Set the path to the service account credentials in the .env file:
Firebase Project ID
Set the Firebase Project ID in the .env file:
Enable FCM
Enable Firebase notifications in the configuration file:
Usage
Sending Notifications
Single User Notification
Multi-Language Notification
Multi-Language Notifications :
Batch Notification
Notification with Related Data
The related model in notifications allows associating a notification with a specific entity (e.g., a Post, Order, or Comment). This is achieved through a morph relationship in the notification model. When sending a notification, the related model's type (related_type) and ID (related_id) are included in the Firebase notification payload, allowing the frontend to handle and display notifications dynamically.
How It Works: Morph Relationship in Notification Model The notification system supports polymorphic relations, meaning a notification can be associated with any model (e.g., Post, Order, User).
Sending Related Model in Firebase Payload
When a related model is assigned, its model type and model ID are sent as part of the Firebase notification payload. This allows the frontend to recognize which entity the notification refers to and navigate users to the appropriate screen.
Alternatively, you can use setRelatedModel() to assign the related model separately:
Notification with Extra Fields
Set extra fields for the notification. like (Image, Color, Sound, Tag)
Implementing HasNotification
If using Firebase ensure your Recipient model implements the HasNotification interface:
Disabling Persistence
Disable in Configuration
Disable Per Notification
Disable Sending Notification
You can disable notifications for a specific notification or globally.
Disable in Configuration
Disable for a Specific Notification
Use disableSendNotification() to prevent sending this specific notification.
Advanced Configuration
Batch Processing
comment: <> ()
Customize Table Names
Update table_names in the configuration file to match your database schema.
Contributing
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Submit a pull request with a detailed description of your changes.
All versions of notification with dependencies
illuminate/support Version ^8.0 || ^9.0 || ^10.0 | ^11.0
astrotomic/laravel-translatable Version ^11.12
google/auth Version ^1.41