PHPackages                             laravel-enso/categories - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. laravel-enso/categories

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laravel-enso/categories
=======================

Hierarchical category management for Laravel Enso

3.10.0(1mo ago)011.7k↓50.8%2[1 PRs](https://github.com/laravel-enso/categories/pulls)1MITPHPPHP ^8.2

Since Mar 4Pushed 1mo ago3 watchersCompare

[ Source](https://github.com/laravel-enso/categories)[ Packagist](https://packagist.org/packages/laravel-enso/categories)[ Docs](https://github.com/laravel-enso/categories)[ RSS](/packages/laravel-enso-categories/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (35)Versions (106)Used By (1)

Categories
==========

[](#categories)

[![License](https://camo.githubusercontent.com/8e960a9d3780d38e1cafbbaffb205087ec8c3f52ec105f2a38186038d9c701ee/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f63617465676f726965732f6c6963656e7365)](LICENSE)[![Stable](https://camo.githubusercontent.com/e28c3de8b002a298171cd5cf8fe2d2a7d3d5e5301237afd2ee65022be181cffc/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f63617465676f726965732f76657273696f6e)](https://packagist.org/packages/laravel-enso/categories)[![Downloads](https://camo.githubusercontent.com/537b5898a98c8bccab10e4b999dffea1c7c58fe68d9b13d84358a0d397aebb11/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f63617465676f726965732f646f776e6c6f616473)](https://packagist.org/packages/laravel-enso/categories)[![PHP](https://camo.githubusercontent.com/da7cf113b588d26fe679dfefe4a15009272ed358ad4e786ad3c78b45faa61d69/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e322532422d3737376262342e737667)](composer.json)[![Issues](https://camo.githubusercontent.com/f1b4678333c6a7dd958096278e1ab6715088e6be29118c68952b80d5e09edee6/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f63617465676f726965732e737667)](https://github.com/laravel-enso/categories/issues)[![Merge Requests](https://camo.githubusercontent.com/2d107ab6d9dbb01fb13590bb66c747ef749d73195998f1c51224a85869e2ae50/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f63617465676f726965732e737667)](https://github.com/laravel-enso/categories/pulls)

Description
-----------

[](#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
------------

[](#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
--------

[](#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
-----

[](#usage)

### Basic model 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

[](#select-labels)

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

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

### Frontend integration

[](#frontend-integration)

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

API
---

[](#api)

### HTTP routes

[](#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
----------

[](#depends-on)

Required Enso packages:

- [`laravel-enso/core`](https://docs.laravel-enso.com/backend/core.html) [↗](https://github.com/laravel-enso/core)
- [`laravel-enso/data-import`](https://docs.laravel-enso.com/backend/data-import.html) [↗](https://github.com/laravel-enso/data-import)
- [`laravel-enso/dynamic-methods`](https://docs.laravel-enso.com/backend/dynamic-methods.html) [↗](https://github.com/laravel-enso/dynamic-methods)
- [`laravel-enso/files`](https://docs.laravel-enso.com/backend/files.html) [↗](https://github.com/laravel-enso/files)
- [`laravel-enso/forms`](https://docs.laravel-enso.com/backend/forms.html) [↗](https://github.com/laravel-enso/forms)
- [`laravel-enso/helpers`](https://docs.laravel-enso.com/backend/helpers.html) [↗](https://github.com/laravel-enso/helpers)
- [`laravel-enso/migrator`](https://docs.laravel-enso.com/backend/migrator.html) [↗](https://github.com/laravel-enso/migrator)
- [`laravel-enso/permissions`](https://docs.laravel-enso.com/backend/permissions.html) [↗](https://github.com/laravel-enso/permissions)
- [`laravel-enso/products`](https://docs.laravel-enso.com/backend/products.html) [↗](https://git.xtelecom.ro/laravel-enso/products)
- [`laravel-enso/rememberable`](https://docs.laravel-enso.com/backend/rememberable.html) [↗](https://github.com/laravel-enso/rememberable)
- [`laravel-enso/select`](https://docs.laravel-enso.com/backend/select.html) [↗](https://github.com/laravel-enso/select)
- [`laravel-enso/tables`](https://docs.laravel-enso.com/backend/tables.html) [↗](https://github.com/laravel-enso/tables)

Companion frontend package:

- [`@enso-ui/categories`](https://docs.laravel-enso.com/frontend/categories.html) [↗](https://github.com/enso-ui/categories)

Contributions
-------------

[](#contributions)

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

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

###  Health Score

59

—

FairBetter than 98% of packages

Maintenance91

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~8 days

Total

89

Last Release

43d ago

Major Versions

0.9.18 → 1.0.02020-06-26

1.1.3 → 2.0.02020-07-30

2.4.2 → 3.0.02022-02-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (51 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (39 commits)")[![AbdullahiAbdulkabir](https://avatars.githubusercontent.com/u/33360580?v=4)](https://github.com/AbdullahiAbdulkabir "AbdullahiAbdulkabir (32 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (25 commits)")[![vmcvlad](https://avatars.githubusercontent.com/u/37445394?v=4)](https://github.com/vmcvlad "vmcvlad (14 commits)")[![GITmanuela](https://avatars.githubusercontent.com/u/44998004?v=4)](https://github.com/GITmanuela "GITmanuela (11 commits)")

---

Tags

categoriescategorylaravelcategorieslaravel-ensocategory-management

### Embed Badge

![Health badge](/badges/laravel-enso-categories/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-enso-categories/health.svg)](https://phpackages.com/packages/laravel-enso-categories)
```

###  Alternatives

[laravel-enso/localisation

Language and translation management for Laravel Enso

1362.8k11](/packages/laravel-enso-localisation)[laravel-enso/core

The backend shell of a Laravel Enso application

3465.3k206](/packages/laravel-enso-core)[laravel-enso/tutorials

Tutorial management backend for Laravel Enso

1140.7k](/packages/laravel-enso-tutorials)[laravel-enso/data-import

Excel Importer dependency for Laravel Enso

2044.0k6](/packages/laravel-enso-data-import)[laravel-enso/roles

Role management for Laravel Enso

1044.9k32](/packages/laravel-enso-roles)[laravel-enso/permissions

Permission management for Laravel Enso

1244.2k52](/packages/laravel-enso-permissions)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
