laravel-enso/categories 问题修复 & 功能扩展

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

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

laravel-enso/categories

Composer 安装命令:

composer require laravel-enso/categories

包简介

Hierarchical category management for Laravel Enso

README 文档

README

License Stable Downloads PHP Issues Merge Requests

Description

Categories is Laravel Enso's reusable hierarchical category management package.

It provides the backend flow for storing, editing, listing, reordering, importing, and decorating nested categories, together with form and table builders that plug directly into the Enso admin UI. The package also supports optional category images, featured categories, select-friendly labels, and tree-shaped API payloads for frontend consumers.

Installation

This package comes pre-installed in Laravel Enso distributions that need category administration.

For standalone package installation inside an Enso-based application:

composer require laravel-enso/categories

The package auto-registers its service provider, loads its routes and migrations, and merges the enso.categories configuration namespace.

Run the migrations after installation:

php artisan migrate

If you want to publish the package config or its factory stubs:

php artisan vendor:publish --tag=categories-config
php artisan vendor:publish --tag=categories-factory

Features

  • Stores categories in a self-referencing tree through parent_id.
  • Keeps siblings ordered automatically through order_index and the global Ordered scope.
  • Exposes full CRUD endpoints for category administration.
  • Supports drag-and-drop style reorder and parent reassignment through the move() workflow.
  • Builds frontend-ready form payloads through the Enso forms builder.
  • Builds table metadata and data endpoints through the Enso tables builder.
  • Returns nested category trees with image metadata for UI consumers.
  • Generates select-compatible labels such as Parent > Child.
  • Supports optional category images through Enso files integration.
  • Restricts image uploads to top-level categories only.
  • Supports featured categories through the is_featured flag and featured() scope.
  • Includes import and validation classes for category dataset ingestion.
  • Provides helper methods for parent trees, subtree flattening, depth, and level calculations.

::: warning Note Only top-level categories can have images attached. Upload validation blocks image uploads for nested categories.

The maximum nesting depth is controlled through CATEGORIES_MAX_NESTING_LEVEL. :::

Usage

Basic model usage

Create a top-level category:

use LaravelEnso\Categories\Models\Category;

$category = Category::create([
    'name' => 'Solar Panels',
    'is_featured' => true,
]);

Create a child category:

$subcategory = Category::create([
    'name' => 'Monocrystalline',
    'parent_id' => $category->id,
    'is_featured' => false,
    'order_index' => Category::nextIndex($category->id),
]);

Move a category to a different parent and position:

$subcategory->move(orderIndex: 1, parentId: null);

Read the nested tree:

$tree = Category::tree();

Inspect hierarchy helpers:

$level = $subcategory->level();
$depth = $category->depth();
$parentTree = $subcategory->parentTree();
$flattenedIds = $category->flattenCurrentAndBelowIds();

Select labels

Use the label resource when a dropdown needs the full breadcrumb:

$options = Category::with('recursiveParent')
    ->get()
    ->map
    ->label();

Frontend integration

The package ships the backend routes and payload builders used by the Enso categories administration UI.

API

HTTP routes

  • GET api/administration/categories
  • GET api/administration/categories/create
  • GET api/administration/categories/{category}/edit
  • GET api/administration/categories/options
  • POST api/administration/categories
  • GET api/administration/categories/initTable
  • GET api/administration/categories/tableData
  • POST api/administration/categories/{category}/upload
  • PATCH api/administration/categories/{category}/move
  • PATCH api/administration/categories/{category}
  • DELETE api/administration/categories/{category}
  • DELETE api/administration/categories/image/{category}

Depends On

Required Enso packages:

Companion frontend package:

Contributions

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

laravel-enso/categories 适用场景与选型建议

laravel-enso/categories 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11.66k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 laravel-enso/categories 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-04