Slug plugin screenshot
Dark mode ready
Multilingual support
Supports v5.x

Slug

Community

Plugin to generate and manage slugs automatically.

Tags: Form Field
Supported versions:
5.x 4.x
Novius avatar Author: Novius

Package health

Beta

Automated checks of this plugin's Composer package

70 / 100
Security 52
Maintenance 90
Ecosystem 100
15 checks
Third-party plugin. This is built by the community, not the Filament team. Filament does not review, endorse, or vet the security of plugins outside the filament/ namespace. Review the source and install at your own risk. Found malware or an unresolved security issue the author won't address? Report it .
Powered by Plumb Last scanned 3 days ago

Documentation

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.