misaf / vendra-tagger
Tenant-aware tag management and Filament administration for Vendra
Requires
- php: ^8.3
- awcodes/filament-badgeable-column: ^4.0
- lara-zeus/spatie-translatable: ^2.0.1
- misaf/filament-jalali: ^5.1.4
- misaf/vendra-support: v1.7.1
- spatie/eloquent-sortable: ^5.0.1
- spatie/laravel-package-tools: ^1.93.1
- spatie/laravel-tags: ^4.0
Requires (Dev)
- fakerphp/faker: ^1.24.1
- larastan/larastan: ^3.10.0
- laravel/boost: ^2.4.12
- laravel/pint: ^1.29.3
- misaf/vendra-testing: v1.7.1
- mockery/mockery: ^1.6.12
- nunomaduro/collision: ^8.9.4
- orchestra/testbench: ^11.1
- pestphp/pest: ^4.7.5
- pestphp/pest-plugin-arch: ^4.0.2
- pestphp/pest-plugin-laravel: ^4.1
- pestphp/pest-plugin-profanity: ^4.2.1
- pestphp/pest-plugin-type-coverage: ^4.0.4
- phpstan/extension-installer: ^1.4.3
README
Translated, sortable, and tenant-compatible tag management for Vendra applications, with a Filament administration resource built on spatie/laravel-tags.
Features
- Uses Spatie's translated tag names and slugs
- Preserves custom slugs while generating missing slugs from names
- Uses a sortable
positioncolumn in place of Spatie'sorder_column - Derives optional tenant scoping and assignment from
misaf/vendra-support - Provides permission-backed Filament list, create, view, edit, delete, and reorder operations
- Supports configurable Filament panels and navigation groups
Requirements
- PHP 8.3+
- Laravel 13
- Filament 5
misaf/vendra-supportspatie/laravel-tags
Installation
composer require misaf/vendra-tagger php artisan vendor:publish --tag=tags-migrations php artisan vendor:publish --tag=vendra-tagger-migrations php artisan migrate
Configure Spatie Tags to use the Vendra model in config/tags.php:
use Misaf\VendraTagger\Models\Tagger; return [ 'tag_model' => Tagger::class, ];
The package service provider and Filament plugin are auto-discovered. Optionally publish the package configuration and translations:
php artisan vendor:publish --tag=vendra-tagger-config php artisan vendor:publish --tag=vendra-tagger-translations
Seed the tag-management permissions when the Vendra permission module is installed:
php artisan vendra-tagger:seed
Configuration
config/vendra-tagger.php exposes two integration options:
return [ 'panels' => ['admin'], 'navigation_group' => 'vendra-support::navigation.groups.Content', ];
panels accepts one panel ID or an array of IDs. navigation_group accepts a translation key or literal label and can also be overridden through TaggerPlugin::navigationGroup().
Tenant awareness is not configured here. When a tenant provider binds an available TenantResolver, the package adds and scopes tenant_id; otherwise it operates without tenant ownership.
Usage
Create a tag:
use Misaf\VendraTagger\Models\Tagger; $tag = Tagger::findOrCreate('Featured', type: 'content', locale: 'en');
Create a tag with an explicit translated slug:
$tag = Tagger::query()->create([ 'name' => ['en' => 'Featured products'], 'slug' => ['en' => 'hand-picked'], 'type' => 'content', ]);
Load ordered tags by type:
$tags = Tagger::withType('content')->get();
Attach tags to an Eloquent model using Spatie's trait:
use Illuminate\Database\Eloquent\Model; use Spatie\Tags\HasTags; final class Article extends Model { use HasTags; } $article->attachTag('Featured', 'content');
Vendra consumer integrations
Tagger binds the shared Support TagResolver. Product, User, Blog, Affiliate, Attribute, and FAQ detect that capability and enable their tag relations and Filament fields without depending on this package.
Create tags with the consumer's reserved type (product, user, blog, affiliate, attribute, or faq):
$tag = Tagger::findOrCreate('Featured', type: 'product', locale: 'en');
Do not add Product imports or dependencies to Tagger. Shared relationship metadata belongs to misaf/vendra-support.
Filament
By default, tag management is available on the admin panel in the shared Content navigation group. The resource supports translated name and slug editing, filtering, sorting, and drag-and-drop position updates. Names and slugs are validated within the current tenant and tag type; the type itself may be reused by any number of tags.
Testing
Run the package checks from the package directory:
composer test
composer analyse
From the Vendra monorepo:
vendor/bin/pest packages/vendra-tagger/tests vendor/bin/phpstan analyse packages/vendra-tagger/src packages/vendra-tagger/database --memory-limit=2G
License
MIT. See LICENSE.