定制 backstage/announcements 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

backstage/announcements

最新稳定版本:v2.0.0-beta14

Composer 安装命令:

composer require backstage/announcements

包简介

This is my package backstage-announcements

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A powerful Filament plugin for managing announcements in your Laravel application. Create, manage, and display announcements with customizable scopes, colors, and navigation controls.

Installation

You can install the package via composer:

composer require backstage/announcements

Important

If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs first.

After setting up a custom theme add the plugin's views to your theme css file or your app's css file if using the standalone packages.

@source '../../../../vendor/backstage/announcements/resources/**/*.blade.php';

You can publish and run the migrations with:

php artisan vendor:publish --tag="backstage-announcements-migrations"
php artisan migrate

Optionally, you can publish the views using

php artisan vendor:publish --tag="backstage-announcements-views"

This is the contents of the published config file:

return [
];

Usage

Add the plugin to your Filament panel provider:

use Backstage\Announcements\AnnouncementsPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        ->plugins([
            AnnouncementsPlugin::make(),
        ]);
}

Navigation Control

Control whether the announcements resource appears in the navigation menu:

AnnouncementsPlugin::make()
    ->canRegisterNavigation(false) // Hide from navigation
AnnouncementsPlugin::make()
    ->canRegisterNavigation(true) // Show in navigation (default)

Forced Scopes

Limit which scopes (resources/pages) are available when creating announcements. You can specify the full class names of resources or pages:

AnnouncementsPlugin::make()
    ->forceScopes([
        'App\\Filament\\Resources\\Users\\UserResource',
        'App\\Filament\\Resources\\Products\\ProductResource',
        'App\\Filament\\Pages\\Dashboard',
    ])

The plugin will automatically match these class names to the formatted scope names that appear in the dropdown, so users will see friendly names like "Users (list)" instead of the full class names. The form automatically converts between class names (stored in database) and formatted names (displayed in UI) using the formatStateUsing() method.

Creating Announcements

Once configured, you can create announcements through the Filament interface:

  1. Title: The announcement title
  2. Content: The announcement content (supports HTML)
  3. Scopes: Select which resources/pages the announcement should appear on
  4. Color: Choose a color theme for the announcement

Displaying Announcements

Announcements are automatically displayed on the selected scopes using the included Livewire component. The component handles:

  • Dismissal tracking per user
  • Color theming
  • Responsive design
  • Accessibility features

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-14