Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Filament Slug

Laravel Filament Slug Laravel Package

novius/laravel-filament-slug

Adds a Slug form field for Laravel Filament. Generate slugs from a TextInput, optionally conditionally, while keeping TextInput features like validation rules and unique checks. Requires PHP 8.2+, Laravel 11+, Filament 4.

View on GitHub
Deep Wiki
Context7

A Laravel Filament slug form field

Frequently asked questions about Laravel Filament Slug
How do I add a Slug field to a Filament resource form?
Use `Slug::make('slug')->fromField($title)` in your resource’s `form()` method, where `$title` is the TextInput instance. The slug will auto-generate from the title field. Add validation rules like `required()`, `unique()`, or `regex()` just like a TextInput.
Can I conditionally skip slug generation?
Yes. Pass a closure to `fromField()` as the second argument (e.g., `->fromField($title, fn(Get $get) => !$get('is_published'))`). This skips slug generation if the condition returns true, such as for unpublished drafts.
Does this package work with Laravel 10 or Filament 3?
No. This package requires **Laravel 11+** and **Filament 4+**. It leverages Filament’s form API, which changed significantly in Filament 4, so older versions are unsupported.
How do I handle duplicate slugs (e.g., auto-increment suffixes like `/post-2`)?
The package doesn’t include built-in collision handling. Use Laravel’s `Str::slug()` with custom logic (e.g., a database constraint or observer) or override the `generate()` method to append suffixes manually.
Will this work with multilingual content (e.g., non-English characters)?
By default, it uses PHP’s `Str::slug()`, which may not handle multilingual characters optimally. For custom formats (e.g., underscores), override the `generate()` method or use a third-party slug library like `spatie/laravel-sluggable`.
Can I use this in Filament Pages (not just Resources)?
Yes. The Slug field works anywhere Filament forms are used, including Pages. Just include it in the `form()` method schema, just like in Resources. Example: `Slug::make('slug')->fromField($name)`.
Does this package support bulk slug generation in Filament tables?
Yes, but with limitations. Slugs generated via `fromField()` won’t auto-update in bulk actions (e.g., `update()`). For bulk operations, use Filament’s `afterStateUpdated` or handle slugs in a custom table action.
How do I test slug generation in my Laravel tests?
Mock the `fromField()` closure or use `partialMock()` to test slug generation logic. For validation, test with `->assertHasNoFormErrors()` or `->assertHasFormErrors()`. Example: `$form->fill(['title' => 'Test Post'])->assertSet('slug', 'test-post').`
Is there a performance impact for real-time slug generation?
Yes, real-time generation triggers validation and potential database queries (e.g., `unique()` checks). For better performance, use `live(false)` or defer generation with `afterStateUpdated()` to batch slug creation.
What are the alternatives to this package?
For Filament, consider `spatie/laravel-sluggable` (model-level slugs) or `filament/spatie-laravel-sluggable` (Filament integration). For custom solutions, use `Str::slug()` in observers or accessors. However, this package is the only dedicated Filament Slug form field.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle