定制 lee-to/moonshine-tree-resource 二次开发

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

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

lee-to/moonshine-tree-resource

最新稳定版本:4.0.0

Composer 安装命令:

composer require lee-to/moonshine-tree-resource

包简介

Tree resource for moonshine

README 文档

README

A modern, responsive tree component for MoonShine with drag & drop sorting, compact mode, and customizable content display.

Features

  • 🚀 Drag & Drop Sorting - Sort and reorder items with ease
  • 📱 Mobile First Design - Responsive and touch-friendly
  • 🎯 Compact Mode - Dense layout for data-heavy interfaces
  • 🎨 Customizable Content - Flexible title, badge, and description
  • 🌓 Dark Mode Support - Integrates seamlessly with MoonShine themes
  • Optimized Performance - Lightweight CSS with MoonShine tokens

Requirements

  • MoonShine v4.0+

Compatibility

MoonShine TreeResource
2.0+ 1.0+
3.0+ 2.0+
4.0+ 3.0+

Installation

composer require lee-to/moonshine-tree-resource
php artisan vendor:publish --tag=moonshine-tree-assets

Quick Start

Extend the TreeResource class instead of the base ModelResource

use Leeto\MoonShineTree\Resources\TreeResource;

class CategoryResource extends TreeResource
{
    // Required properties
    protected string $column = 'title';

    protected string $sortColumn = 'sorting';

    // ...

    // Required methods
    public function treeKey(): ?string
    {
        return 'parent_id'; // Foreign key for parent-child relationship
    }

    public function sortKey(): string
    {
        return 'sorting'; // Column for sorting
    }
}

And add a component to IndexPage

use Leeto\MoonShineTree\View\Components\TreeComponent;

protected function mainLayer(): array
    {
        return [
            ...$this->getPageButtons(),
            TreeComponent::make($this->getResource()),
        ];
    }

Or override list component

use Leeto\MoonShineTree\View\Components\TreeComponent;

public function modifyListComponent(ComponentContract $component): ComponentContract
{
    return TreeComponent::make($this->getResource());
}

Custom Content Display

public function treeItemTitle(Model $item): string
{
    return $item->{$this->getColumn()};
}

public function treeItemBadgeText(Model $item): string
{
    return $item->products_count ?? ''; // Show product count as badge
}

public function treeItemBadgeColor(Model $item): string
{
    return Color::PRIMARY; // Use Color enum for better type safety
}

public function treeItemDescription(Model $item): string
{
    return $item->short_description ?? ''; // Additional description
}

Configuration Options

public function sortable(): bool
{
    return true; // Enable/disable drag & drop sorting
}

public function wrappable(): bool
{
    return true; // Enable/disable expand/collapse functionality
}

public function compactTree(): bool
{
    return false; // Enable compact mode for dense layouts
}

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-17