定制 kylemassacre/laravel-menus 二次开发

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

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

kylemassacre/laravel-menus

最新稳定版本:12.0

Composer 安装命令:

composer require kylemassacre/laravel-menus

包简介

Laravel Menu management

README 文档

README

Usage Example

To create menus in your Laravel application, you should create a file at app/Support/menus.php. This file will be automatically loaded by the package's service provider.

Basic Menu Creation

<?php

use KyleMassacre\Menus\Facades\Menu;
use KyleMassacre\Menus\MenuBuilder;

// Create a menu
Menu::create('main-menu', function (MenuBuilder $menu) {
    // Add items to the menu
    $menu->add([
        'route' => 'home',
        'title' => 'Home',
        'icon' => 'fa fa-home fa-fw me-2',
    ]);
    
    // Add a menu item with a URL instead of a route
    $menu->add([
        'url' => '/about',
        'title' => 'About',
        'icon' => 'fa fa-info fa-fw me-2',
    ]);
    
    // Add a dropdown menu
    $menu->dropdown('User', function ($sub) {
        $sub->add([
            'route' => 'profile',
            'title' => 'Profile',
            'icon' => 'fa fa-user fa-fw me-2',
        ]);
        $sub->add([
            'route' => 'logout',
            'title' => 'Logout',
            'icon' => 'fa fa-sign-out fa-fw me-2',
        ]);
    });
});

Rendering Menus

To render a menu in your blade templates:

{!! Menu::render('main-menu') !!}

Or with a specific presenter:

{!! Menu::render('main-menu', 'App\\Http\\Presenters\\MainMenuPresenter') !!}

Important Notes

  1. Ensure your routes are defined before creating menus that reference them
  2. For route-based menu items, use 'route' => 'route.name' or 'route' => ['route.name', ['param' => 'value']] for routes with parameters
  3. For URL-based menu items, use 'url' => '/path/to/page'

Laravel Menus

Latest Version on Packagist Software License GitHub Actions Workflow Status Scrutinizer Coverage Scrutinizer quality (GitHub/Bitbucket) with branch Total Downloads

kylemassacre/laravel-menus is a laravel package which created to manage menus. It has a feature called presenters which enables easy styling and custom structure of menu rendering.

This package is a re-published, re-organised and maintained version of nwidart/laravel-menus, which isn't maintained anymore. This package is used in AsgardCMS.

With one big added bonus that the original package didn't have: tests.

Documentation

You'll find installation instructions and full documentation on https://nwidart.com/laravel-menus/.

Credits

License

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-03-31