kaveh/notification-service
最新稳定版本:1.0.0
Composer 安装命令:
composer require kaveh/notification-service
包简介
README 文档
README
A customizable notification package for Laravel.
Installation
Run the following command to install the package:
composer require kaveh/notification-service
Configuration
-
Register the Service Provider
Add the following line tobootstrap/providers.php:Kaveh\NotificationService\NotificationServiceProvider::class,
-
Update
composer.json
Add the following to theautoloadsection:"autoload": { "psr-4": { "Kaveh\\NotificationService\\": "vendor/kaveh/notification-service/src/" } }
Then, run:
composer dump-autoload
-
Migrate Notification Tables
Run the following command to create necessary database tables:php artisan notification:migrate
-
Extend the User Model
Replace the default LaravelAuthenticatableimport in yourUsermodel:Before:
use Illuminate\Foundation\Auth\User as Authenticatable;
After:
use Kaveh\NotificationService\Abstracts\Authenticatable;
And add this method in your model:
public function getId() { return $this->id; }
-
Notification Configuration
- Notification Type: Define the notification type, e.g.,
user_login,order_created, etc. - Notification Channel: Specify the notification delivery method:
email,sms,in-app, etc. - Notification Preferences:
We recommend using an event-listener to automatically set user notification preferences upon registration. This determines whether a user has granted permission for notifications.
- Notification Type: Define the notification type, e.g.,
Usage
Create a New Notification
Run the following command to generate a notification class:
php artisan make:notification-service {name}
Send a Notification
To send a notification, use:
NotificationService::sendNotification(notificationClass, UserModel, NotificationType, ?array data = []);
Enjoy using Laravel Notification Service! 🚀
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-02-17