novius/laravel-filament-slug

A Laravel Filament Forms slug field.

Installs: 139

Dependents: 3

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/novius/laravel-filament-slug

1.0.0 2026-02-18 13:54 UTC

This package is auto-updated.

Last update: 2026-02-18 15:42:04 UTC


README

Laravel Filament Slug

Novius CI Packagist Release License: AGPL v3

Introduction

This package add a Slug field to Filament Forms

Requirements

  • PHP >= 8.2
  • Laravel >= 11.0
  • Laravel Filament >= 4

Installation

composer require novius/laravel-filament-slug

Usage

class YourResource extends Resource
{
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                $title = TextInput::make('title')
                    ->required(),
    
                Slug::make('slug')
                    // First parameter of fromField() must be the TextInput instance from which the slug is generated.
                    // Second parameter is optional. If passed, must be a closure returning if the slug generation should be skip or not.
                    ->fromField($title, fn (Get $get) => ! $get('other_value'))
                    // Slug inherit from TextInput. You can use all other method of TextInput. 
                    ->required()
                    ->string()
                    ->regex('/^(\/|[a-zA-Z0-9-_]+)$/')
                    ->unique(
                        YourModel::class,
                        'slug',
                        ignoreRecord: true
                    ),
            ]);
    }
}

Lint

Run php-cs with:

composer run-script lint

Contributing

Contributions are welcome!

Leave an issue on GitHub, or create a Pull Request.

Licence

This package is under GNU Affero General Public License v3 or (at your option) any later version.