承接 pestopancake/laravel-backpack-database-notifications 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

pestopancake/laravel-backpack-database-notifications

最新稳定版本:1.0.10

Composer 安装命令:

composer require pestopancake/laravel-backpack-database-notifications

包简介

Database notifications interface for Laravel Backpack

README 文档

README

Packagist Version Build Status StyleCI

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

php artisan notifications:table
php artisan migrate

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

统计信息

  • 总下载量: 7.54k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 18
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-27