pestopancake/laravel-backpack-database-notifications
Composer 安装命令:
composer require pestopancake/laravel-backpack-database-notifications
包简介
Database notifications interface for Laravel Backpack
README 文档
README
Easily add an admin interface for standard Laravel database notifications. This package includes:
- a sidebar item, with an optional notification count for the current user (refreshed with AJAX every second)
- an interface that shows the notifications in the database for the current user, with their (optional) action buttons;
The only thing left for you to do is to actually trigger notifications for your admins, wherever you want, using the standard Laravel syntax (example below).
Prerequisites
- Have Laravel Backpack installed backpack/crud v4.0.* | 4.1.*
- Follow the steps for laravel's database notifications prerequisites, e.g:
php artisan notifications:table
php artisan migrate
- Have Permission Manager installed Laravel-Backpack/PermissionManager
Installation
Backpack v5 / v6
composer require pestopancake/laravel-backpack-database-notifications
Backpack v4
composer require pestopancake/laravel-backpack-database-notifications:1.0.6
Usage
Publish the config file:
php artisan vendor:publish --provider="Pestopancake\\LaravelBackpackNotifications\\LaravelBackpackNotificationsServiceProvider" --tag=config
Show in side menu
Add a menu item to your 'resources/views/vendor/backpack/base/inc/sidebar_content.blade.php' by running:
php artisan backpack:add-menu-content "@include('backpack-database-notifications::sidebarMenuItem')"
Admin view
With the Permission Manager package installed you can assign the permission 'notifications admin' to users for them to see admin functionality.
To change the permission name edit 'admin_permission_name' in the databasenotifications config file.
Currently users with the admin permission can see/dismiss notifications for all users.
Create a notification
Use the included generic notification
use Pestopancake\LaravelBackpackNotifications\Notifications\DatabaseNotification; $user = backpack_user(); $user->notify(new DatabaseNotification( $type = 'info', // info / success / warning / error $message = 'Test Notification', $messageLong = 'This is a longer message for the test notification '.rand(1, 99999), // optional $href = '/some-custom-url', // optional, e.g. backpack_url('/example') $hrefText = 'Go to custom URL' // optional ));
Use in any other notification
The toArray method of the notification should be in this format:
return [ 'type' => "info", // info / success / warning / error 'message' => "", 'message_long' => "", // optional 'action_href' => "", // optional, e.g. backpack_url('/example') 'action_text' => "", // optional ];
The type will affect the colour of the toast notification (if toasts are enabled in the config)
Troubleshooting
Notification not created
- Make sure the model you are notifying matches the model defined in your backpack config at backpack.base.user_model_fqn (found in config/backpack/base.php)
Change log
See the changelog for more information on what has changed recently.
Todo
- Add unit tests
- translatable text
- notification preferences
pestopancake/laravel-backpack-database-notifications 适用场景与选型建议
pestopancake/laravel-backpack-database-notifications 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.34k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2021 年 01 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notifications」 「laravel」 「laravel backpack」 「database notifications」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pestopancake/laravel-backpack-database-notifications 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pestopancake/laravel-backpack-database-notifications 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pestopancake/laravel-backpack-database-notifications 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
Extended summernote fields for laravel backpack
Captures outgoing SMS notifications
Use a translation namespace vor mutliple translation files.
Ready to use Documents Backpack CRUD with API route for eg. privacy statement, imprint, sbt or gtc
Dropzone field for Laravel Backpack
统计信息
- 总下载量: 15.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-01-27
