codelets-mv / notification
这是一个自定义通知,用于在应用程序内部保留用户收到的通知。
v1.2.2
2019-06-13 21:04 UTC
Requires
- webpatser/laravel-uuid: ^3.0
This package is auto-updated.
Last update: 2024-09-14 10:18:42 UTC
README
此包为管理员和用户自定义通知,因此不再使用 Laravel 通知。我为我的项目构建了此自定义通知包,因此如果您想尝试它,请阅读文档。
安装
建议通过 Composer 安装 codelets-mv/notification。
# Install package via composer
composer require codelets-mv/notification
接下来,运行 Composer 命令以安装最新稳定的 codelets-mv/notification 版本
# Update package via composer
composer require codelets-mv/notification --lock
安装后,包将被自动发现。但如果需要,您可以运行
# run for auto discovery <-- If the package is not detected automatically -->
composer dump-autoload
然后运行以下命令,以获取配置的 config/mv-notification.php
# run this to get the configuartion file at config/mv-notification.php <-- read through it --> php artisan vendor:publish --provider="MV\Notification\MvNotificationService"
您需要提供此信息到 .env 文件中,以进行 API 配置
# This is the pagination number you want to paginate with <-- default(10) --> MV_NOTIFICATION_PAGINATE=
用法
请按照以下步骤使用此包
/** * Create a new controller instance. * * @return void */ public function __construct() { //The instance should be either this $this->middleware('auth:admin');//for your admin controller //or $this->middleware('auth');//for your user Controller } /** * --------------------------------- * Fetch Latest Notification Here * -------------------------------- * Passing bool - true - to the function will query admin notification only * @return void */ public function latestNotifications() { Mv::latestNotifications();//Fetching latest notification for user Mv::latestNotifications(true);//Fetching latest notification for admin } /** * -------------------------------- * Fetching all notifications * ------------------------------- * Passing bool - true - to the function will query admin notification only * @return void */ public function allNotifications() { Mv::allNotifications();//Fetching all notifications for user Mv::allNotifications(true);//Fetching all notifications for admin } /** * =------------------------------- * Deleting a single notification * -------------------------------- * Passing bool - true - to the function will query admin notification only * ------------------------------------------------------------------------------ * To achieve single notification create a route that receives a (string) notification_id * Note that this package uses uuids so the notification_id has to be a string * ---------------------------------------------------------------------------------------- * Passing bool - true - to the function will query admin notification only * ----------------------------------------------------------------------------------------------- * @param string $notification_id * @return void */ public function deleteSingleNotification(string $notification_id) { Mv::deleteSingleNotification($notification_id);//For user Mv::deleteSingleNotification($notification_id, true);//For admin } /** * =------------------------------- * Deleting a all notification * -------------------------------- * Passing bool - true - to the function will query admin notification only * ------------------------------------------------------------------------------ * Passing bool - true - to the function will query admin notification only * ---------------------------------------------------------------------------------- * @return void */ public function deleteAllNotifications() { Mv::deleteAllNotifications();//For user Mv::deleteAllNotifications(true);//For admin } /** * -------------------------------- * Creating new notification here * -------------------------------- * In creating notification we need 4 parameters of which 2 are optional that is for user_id and admin_id * ------------------------------------------------------------------------------------------------------- * Also you can have your function that receives the parameters and passes them to Mv::createSystemNotification * -------------------------------------------------------------------------------------------------------------- * @return void */ public function createSystemNotification() { //This is for creating user notifications Mv::createSystemNotification(null, auth()->id(), 'My Notification Subject', 'My Notification Message'); //This is for creating admin notifications Mv::createSystemNotification(auth('admin')->id(), null, 'My Notification Subject', 'My Notification Message'); } /** * --------------------------- * TODO SIMPLE PACKAGE NOTES * ----------------------------------------------------------------------------------------- * For the functions used above can be changed to your own names to call the package names * ----------------------------------------------------------------------------------------- */
版本指导
安全漏洞
对于任何安全漏洞,请发送电子邮件至 MvTechZone。
许可证
此包是开源软件,许可协议为 MIT 协议。