承接 skylark-team/nova-menus 相关项目开发

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

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

skylark-team/nova-menus

Composer 安装命令:

composer require skylark-team/nova-menus

包简介

Advanced hierarchical menu management tool for Laravel Nova with drag-and-drop interface, temporal visibility, and resource integration

README 文档

README

Advanced hierarchical menu management tool for Laravel Nova with intuitive drag-and-drop interface, temporal visibility, resource integration, and comprehensive testing.

Screenshots

Menu Management Interface Main menu management interface with Nova integration

Menu Structure Management Menu item management with hierarchical structure and edit controls

Features

  • 🎯 Drag & Drop Interface: Intuitive Vue.js-based interface with nested drag-and-drop functionality
  • ⏰ Temporal Visibility: Schedule menu items to appear/disappear at specific dates and times
  • 🔗 Resource Integration: Link menu items to any Nova resources with automatic URL generation
  • 📊 Performance Monitoring: Built-in query performance monitoring and optimization suggestions
  • 🌳 Nested Hierarchy: Unlimited nesting levels with configurable depth limits
  • ✅ Comprehensive Testing: 90%+ test coverage with unit, integration, and E2E tests
  • 🎨 Responsive Design: Mobile-friendly interface with accessibility support
  • ⚡ Optimized Queries: Efficient nested set implementation for fast hierarchy operations

Requirements

  • PHP 8.2+
  • Laravel 10.0+
  • Laravel Nova 4.0+ or 5.0+

Installation

You can install the package via Composer:

composer require skylark-team/nova-menus

After installation, publish and run the migrations:

php artisan vendor:publish --tag="menus-migrations"
php artisan migrate

Optionally, you can publish the config file:

php artisan vendor:publish --tag="menus-config"

Register the tool in your NovaServiceProvider:

use Skylark\Menus\MenusTool;

public function tools()
{
    return [
        new MenusTool(),
    ];
}

Usage

Basic Menu Management

  1. Access the Tool: Navigate to "Menus" in your Nova sidebar
  2. Create a Menu: Click "Create Menu" and provide a name and slug
  3. Add Items: Use "Manage Items" to add menu items with drag-and-drop functionality
  4. Configure Links: Set custom URLs or link to Nova resources
  5. Set Visibility: Configure when items should be visible (always, never, or scheduled)

Programmatic Usage

Creating Menus Programmatically

use Skylark\Menus\Models\MenuItem;

// Create a root menu
$menu = MenuItem::create([
    'name' => 'Main Navigation',
    'slug' => 'main-nav',
    'is_root' => true,
    'max_depth' => 6,
]);

// Add menu items
$homeItem = MenuItem::create([
    'menu_id' => $menu->id,
    'name' => 'Home',
    'custom_url' => '/',
    'position' => 1,
]);

$aboutItem = MenuItem::create([
    'menu_id' => $menu->id,
    'name' => 'About',
    'custom_url' => '/about',
    'position' => 2,
]);

Retrieving Menu Data

// Get a menu with all items
$menu = MenuItem::where('slug', 'main-nav')->first();
$items = $menu->children()->visible()->ordered()->get();

// Get hierarchical structure
$tree = MenuItem::where('menu_id', $menu->id)
    ->with('children.children')
    ->whereNull('parent_id')
    ->ordered()
    ->get();

Visibility Filtering

use Carbon\Carbon;

// Get currently visible items
$visibleItems = MenuItem::visible()->get();

// Get items visible at specific time
$futureDate = Carbon::parse('2024-12-25 00:00:00');
$christmasItems = MenuItem::isVisibleAt($futureDate)->get();

// Create scheduled item
MenuItem::create([
    'name' => 'Holiday Special',
    'custom_url' => '/holiday',
    'display_at' => '2024-12-01 00:00:00',
    'hide_at' => '2024-12-31 23:59:59',
]);

Frontend Integration

Blade Templates

@php
$menu = \Skylark\Menus\Models\MenuItem::where('slug', 'main-nav')->first();
$items = $menu ? $menu->children()->visible()->ordered()->get() : collect();
@endphp

<nav class="main-navigation">
    @foreach ($items as $item)
        <a href="{{ $item->getUrl() }}" 
           class="nav-item {{ $item->isCurrentPage() ? 'active' : '' }}">
            {{ $item->name }}
        </a>
        
        @if ($item->children->isNotEmpty())
            <ul class="nav-submenu">
                @foreach ($item->children as $child)
                    <li>
                        <a href="{{ $child->getUrl() }}">{{ $child->name }}</a>
                    </li>
                @endforeach
            </ul>
        @endif
    @endforeach
</nav>

API Usage

// In your controller
public function getMenu($slug)
{
    $menu = MenuItem::where('slug', $slug)->first();
    
    if (!$menu) {
        return response()->json(['error' => 'Menu not found'], 404);
    }
    
    $tree = $menu->children()
        ->visible()
        ->with(['children' => function ($query) {
            $query->visible()->ordered();
        }])
        ->ordered()
        ->get();
    
    return response()->json($tree);
}

Configuration

The config file allows you to customize various aspects of the menu system:

return [
    // Maximum nesting depth
    'max_depth' => 10,
    
    // Performance monitoring
    'performance_monitoring' => env('MENUS_PERFORMANCE_MONITORING', false),
    'slow_query_threshold' => 100, // milliseconds
    'log_slow_queries' => env('MENUS_LOG_SLOW_QUERIES', false),
    
    // Resource integration
    'resources' => [
        'App\\Models\\Page' => [
            'model' => 'App\\Models\\Page',
            'name_field' => 'title',
            'slug_field' => 'slug',
            'route_pattern' => '/pages/{slug}',
        ],
        // Add more resource types...
    ],
    
    // Cache settings
    'cache' => [
        'enabled' => true,
        'ttl' => 3600, // 1 hour
        'key_prefix' => 'menus',
    ],
];

Performance Optimization

Database Optimization

The package includes performance monitoring tools:

# Analyze query performance
php artisan menus:analyze-performance

# Generate optimization recommendations
php artisan menus:analyze-performance --threshold=50 --export=performance-report.json

Recommended Database Indexes

For optimal performance, ensure these indexes exist:

-- Basic indexes
CREATE INDEX idx_menu_items_menu_id ON menu_items(menu_id);
CREATE INDEX idx_menu_items_parent_id ON menu_items(parent_id);
CREATE INDEX idx_menu_items_position ON menu_items(position);

-- Composite indexes for better performance
CREATE INDEX idx_menu_items_menu_parent ON menu_items(menu_id, parent_id);
CREATE INDEX idx_menu_items_parent_position ON menu_items(parent_id, position);
CREATE INDEX idx_menu_items_visibility ON menu_items(is_active, display_at, hide_at);

-- Nested set indexes (if using nested set model)
CREATE INDEX idx_menu_items_lft_rgt ON menu_items(lft, rgt);

Caching

Enable caching for frequently accessed menus:

use Skylark\Menus\Models\MenuItem;

// Cache menu for 1 hour
$menu = Cache::remember("menu.{$slug}", 3600, function () use ($slug) {
    return MenuItem::where('slug', $slug)
        ->with(['children' => function ($query) {
            $query->visible()->ordered();
        }])
        ->first();
});

Testing

The package includes comprehensive tests covering unit, integration, and end-to-end scenarios:

# Run all tests
composer test

# Run with coverage
composer test-coverage

# Run specific test types
vendor/bin/pest tests/Unit
vendor/bin/pest tests/Feature
vendor/bin/pest tests/Performance

# Run E2E tests with Playwright
npm run test:e2e

Test Categories

  • Unit Tests: Model validation, service logic, utilities
  • Feature Tests: API endpoints, database operations, Nova integration
  • Performance Tests: Large dataset handling, query optimization
  • Vue Component Tests: Frontend component functionality
  • E2E Tests: Complete user workflows with Playwright

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/skylark-team/nova-menus.git
cd nova-menus

# Install dependencies
composer install
npm install

# Set up testing environment
cp .env.example .env
php artisan key:generate
php artisan migrate --database=testing

# Run development server
composer run dev

Code Quality

# Format code
composer format

# Check code style
composer lint

# Run static analysis
composer analyse

# Run all quality checks
composer test && composer lint && composer analyse

API Reference

Model Methods

MenuItem Model

// Hierarchy methods
$item->children()           // Get direct children
$item->descendants          // Get all descendants
$item->ancestors           // Get all ancestors
$item->siblings()          // Get siblings

// Visibility methods
MenuItem::visible()        // Scope for visible items
MenuItem::isVisibleAt($date) // Scope for items visible at date
$item->isCurrentlyVisible() // Check if item is visible now

// Utility methods
$item->getUrl()           // Get the item URL
$item->isCurrentPage()    // Check if item matches current page
$item->hasChildren()      // Check if item has children

Service Classes

QueryPerformanceMonitor

use Skylark\Menus\Services\QueryPerformanceMonitor;

$monitor = new QueryPerformanceMonitor();

// Monitor specific operation
$stats = $monitor->monitor(function () {
    return MenuItem::with('children')->get();
});

// Get optimization suggestions
$suggestions = $monitor->getMenuOptimizationSuggestions();

Contributing

Please see CONTRIBUTING.md for details.

Security Vulnerabilities

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

Changelog

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

License

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

Credits

Support

If you discover any issues or have questions, please:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue if needed

For commercial support, please contact us at info@skylark.dev.

skylark-team/nova-menus 适用场景与选型建议

skylark-team/nova-menus 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 08 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「admin」 「menu」 「cms」 「nova」 「navigation」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 skylark-team/nova-menus 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 skylark-team/nova-menus 我们能提供哪些服务?
定制开发 / 二次开发

基于 skylark-team/nova-menus 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-08-29