unusualdope/banner-manager 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

unusualdope/banner-manager

Composer 安装命令:

composer require unusualdope/banner-manager

包简介

A Laravel package for managing banners with Blade directives, Flux UI admin interface, and optional translations

README 文档

README

A Laravel package for managing banners with Blade directives, Flux UI admin interface, and optional multi-language support.

Features

  • Flux UI Integration: Modern, responsive admin interface using Flux components.
  • Group Management: Organize banners into logical groups (e.g., Homepage Hero, Sidebar).
  • Flexible Content: Manage images, titles, descriptions, links, and buttons.
  • Optional Translations: Toggle between single-language and multi-language banners per banner.
  • Smart Carousel: Default view automatically creates an auto-playing carousel for multiple banners.
  • Caching: Optimized performance with automatic cache management.

Installation

The package is installed via local path repository in this project.

Database Setup

Run the migrations:

php artisan migrate

Or publish the migrations first:

php artisan vendor:publish --tag=banner-manager-migrations
php artisan migrate

Configuration

Publish the config file:

php artisan vendor:publish --tag=banner-manager-config

This will create config/banner-manager.php where you can configure:

  • supported_locales: List of languages (e.g., ['it', 'en'])
  • default_locale: Fallback language
  • admin_route_prefix: URL prefix for admin routes (default: admin)
  • default_view: Template for @cmsbanner directive

Usage

Admin Interface

Access the banner manager at: /admin/banner-manager

Managing Groups

  1. Create Group: Click "Create Group" on the index page.
  2. Edit Group: Click "Manage" on any group card. This takes you to the group edit page where you can also manage its banners.

Managing Banners

Banners are managed directly from their parent group's edit page.

  1. Go to a group's edit page.
  2. Scroll to the "Banners" section.
  3. Add Banner: Click the "+" button to open the banner creation page.
  4. Edit Banner: Click the pencil icon on any banner in the list.
  5. Translations: Toggle "Enable translations" to switch between single-language and multi-language mode.
  6. Sort Order: Banners are displayed based on the "Sort Order" field (lower numbers first).

Displaying Banners

Use the @cmsbanner Blade directive in your views:

1. Default View (Carousel)

Displays banners using the default package view. If multiple banners exist in the group, it automatically renders an auto-playing carousel with slide transitions.

@cmsbanner('homepage-hero')

2. Custom View

Pass a custom view path to render banners with your own HTML structure.

@cmsbanner('homepage-hero', ['view' => 'front.banner-manager.hero'])

3. Custom CSS Class

Add custom classes to the banner container.

@cmsbanner('sidebar-ads', ['class' => 'my-8 rounded-xl'])

Programmatic Usage

You can use the BannerService to retrieve banners directly in your controllers or PHP code:

use Unusualdope\BannerManager\Services\BannerService;

$service = app(BannerService::class);

// Get all banners for a group
$banners = $service->getBanners('homepage-hero');

// Get banners for a specific locale
$banners = $service->getBanners('homepage-hero', 'en');

// Clear cache for a group
$service->clearCache('homepage-hero');

Database Structure

banner_groups

  • id, name, slug, description, is_active, timestamps

banners

  • id, banner_group_id
  • sort_order, is_active
  • start_date, end_date
  • is_translatable (boolean)
  • timestamps

banner_translations

  • id, banner_id, locale
  • title, description
  • image, link_url
  • button_text, alt_text
  • additional_data (JSON)
  • timestamps

Publishing Views

To customize the default views:

php artisan vendor:publish --tag=banner-manager-views

This publishes views to resources/views/front/banner-manager/.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-26

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固