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
Requires
- php: >=8.2
- filament/filament: ^4.0 | ^5.0
- laravel/framework: ^11.0 | ^12.0
Requires (Dev)
- larastan/larastan: ^2.0 | ^3.0
- laravel/pint: ^1.7
- orchestra/testbench: ^10.3
- roave/security-advisories: dev-latest
README
Laravel Filament Slug
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.