wsmallnews/category is a Filament category management package built on wsmallnews/filament-nestedset. It provides hierarchical categories, category type management, scopeable data, and optional Filament tenancy support.
- Category tree management powered by
kalnoy/nestedsetthroughwsmallnews/filament-nestedset - Category type records for separating different category trees
- Scopeable category data via
scope_typeandscope_id - Automatic tenant scoping when the current Filament panel supports tenancy
- Filament plugin registration for category pages and category type resources
- Frontend Livewire category tree component
This package ships Laravel Boost AI Guidelines in resources/boost/guidelines/core.blade.php.
Install or enable Laravel Boost in your application, then refresh Boost resources so this package's guidelines are discovered and added to the project overview:
php artisan boost:update --discoverBoost updates the root boost.json and CLAUDE.md automatically. Check those files after running the command to confirm wsmallnews/category is included.
You can install the package via composer:
composer require wsmallnews/categoryThe package provides an install command. By default it also installs its support dependency:
php artisan sn-category:installTo skip dependency installation and interactive prompts:
php artisan sn-category:install --no-deps --no-interactionYou can publish and run only the migrations with:
php artisan vendor:publish --tag="category-migrations"
php artisan migrateYou can publish only the config file with:
php artisan vendor:publish --tag="category-config"Optionally, you can publish the views using:
php artisan vendor:publish --tag="category-views"The package configuration lives in config/sn-category.php:
return [
'scopeable' => [
'scope_type' => 'sn-category',
'scope_id' => 0,
],
'models' => [
'category' => Wsmallnews\Category\Models\Category::class,
'category_type' => Wsmallnews\Category\Models\CategoryType::class,
],
'panel_register' => [
'pages' => [
Wsmallnews\Category\Filament\Pages\Category\CategoryPage::class,
],
'resources' => [
Wsmallnews\Category\Filament\Resources\CategoryTypes\CategoryTypeResource::class,
],
],
];Register the plugin on your Filament panel:
use Wsmallnews\Category\CategoryPlugin;
$panel
->plugin(CategoryPlugin::make());CategoryPlugin registers the pages and resources configured in sn-category.panel_register:
Wsmallnews\Category\Filament\Pages\Category\CategoryPageWsmallnews\Category\Filament\Resources\CategoryTypes\CategoryTypeResource
CategoryPage extends Wsmallnews\Category\Filament\Pages\Category\Base, which extends Wsmallnews\FilamentNestedset\Filament\Pages\NestedsetPage.
The base page automatically resolves or creates a CategoryType for the configured scope, applies the type's level to the nestedset tree, and scopes category records by:
scope_typescope_idtype_idteam_idwhen tenancy is enabled
Create your own page by extending the base page:
<?php
namespace App\Filament\Pages;
use Wsmallnews\Category\Filament\Pages\Category\Base;
class ProductCategories extends Base
{
protected static ?string $slug = 'product-categories';
protected static ?string $scopeType = 'product';
protected static int $scopeId = 0;
protected static ?int $level = 3;
}Wsmallnews\Category\Models\Category uses Kalnoy\Nestedset\NodeTrait and defines scope attributes for nestedset scoping:
public function getScopeAttributes(): array
{
return ['scope_type', 'scope_id', 'type_id', 'team_id'];
}When tenancy is disabled, team_id is not added to the scope attributes.
The service provider registers the category tree Livewire component as:
<livewire:sn-category-components-categories />Use the component when you need a frontend category tree display that follows the package conventions.
| Category | Namespace |
|---|---|
| Plugin | Wsmallnews\Category\CategoryPlugin |
| ServiceProvider | Wsmallnews\Category\CategoryServiceProvider |
| Page Base | Wsmallnews\Category\Filament\Pages\Category\Base |
| Page Implementation | Wsmallnews\Category\Filament\Pages\Category\CategoryPage |
| Page Widget | Wsmallnews\Category\Filament\Pages\Category\Widgets\Category |
| Category Type Resource | Wsmallnews\Category\Filament\Resources\CategoryTypes\CategoryTypeResource |
| Category Model | Wsmallnews\Category\Models\Category |
| Category Type Model | Wsmallnews\Category\Models\CategoryType |
| Frontend Component | Wsmallnews\Category\Livewire\Components\Categories |
| Install Command | Wsmallnews\Category\Commands\CategoryInstallCommand |
| Utils | Wsmallnews\Category\Support\Utils |
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.