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.
TextInput, ensuring UI consistency (validation, styling, and behavior) with minimal deviation from Filament’s native patterns. This reduces cognitive load for developers and maintains a cohesive admin panel experience.Resource/Page definitions, avoiding global state or external dependencies. This aligns with Filament’s resource-centric architecture, where slugs are typically tied to editable entities (e.g., blog posts, products).fromField() method abstracts the relationship between source fields (e.g., title) and slugs, a common requirement in content management systems. This eliminates repetitive boilerplate in controllers or observers, adhering to Filament’s principle of declarative UI logic.TextInput validation methods (e.g., regex(), unique(), required()), enabling seamless integration with existing validation rules. This reduces the need for custom logic or middleware to enforce slug constraints.Slug::make()->fromField($title)). No migrations, service providers, or complex setup, making it ideal for rapid prototyping or iterative development.fromField(), enabling flexibility for non-standard use cases (e.g., slugs derived from description or custom_metadata).is_published is false), reducing hardcoded rules and improving maintainability.TextInput methods enables fine-grained validation without workarounds, such as enforcing regex patterns or uniqueness constraints./post-2). Requires application-level solutions (e.g., database constraints, custom observers, or manual overrides), adding complexity for high-traffic applications.Str::slug(), which may not handle multilingual characters or custom formats (e.g., underscores vs. hyphens) optimally. May need overrides or additional logic for non-English content.live(false) or defer generation via afterStateUpdated to optimize performance.unique() method, requiring careful coordination to avoid validation errors or race conditions.unique() method?Str::slug() behavior is insufficient?TextInput with afterStateUpdated or a custom Livewire component achieve the same result with lower risk or greater flexibility?TextInput ensures UI and validation consistency with Filament’s form system.novius/laravel-filament-slug) with no additional services, migrations, or configuration files, reducing deployment complexity.regex(), unique(), required()), enabling reuse of existing rules and reducing custom logic.Resource (e.g., PostResource) to validate the package’s behavior, edge cases, and integration with existing workflows. This minimizes risk and allows for iterative feedback.Resources as needed, ensuring compatibility with each application’s specific requirements (e.g., conditional generation, custom validation).unique, nullable). Use Laravel migrations to ensure consistency:
Schema::table('posts', function (Blueprint $table) {
$table->string('slug')->unique()->nullable()->after('title');
});
unique() method. Resolve conflicts by either:
TextInput field as a source, enabling flexibility for non-standard use cases (e.g., slugs derived from description or custom_metadata).is_draft is true), reducing hardcoded rules.How can I help you explore Laravel packages today?