Skip to content

Commit

Permalink
fix: adds validation unique for slug and key (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhtrungit97 authored Nov 1, 2024
1 parent 0266bd8 commit 3c289ef
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/Filament/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public static function form(Form $form): Form
->maxLength(191),
Forms\Components\TextInput::make('slug')
->required()
->unique(ignoreRecord: true)
->maxLength(191),
Forms\Components\Select::make('parent_id')
->label('Parent Category')
Expand Down
11 changes: 6 additions & 5 deletions app/Filament/Resources/FormsResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ public static function form(Form $form): Form
return $form
->schema([
TextInput::make('name')
->label('Name')
->required()
->live(debounce: 500)
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state)))
->maxLength(191),
->label('Name')
->required()
->live(debounce: 500)
->afterStateUpdated(fn (Set $set, ?string $state) => $set('slug', Str::slug($state)))
->maxLength(191),

TextInput::make('slug')
->label('Slug')
->required()
->unique(ignoreRecord: true)
->maxLength(191),

Repeater::make('fields')
Expand Down
1 change: 1 addition & 0 deletions app/Filament/Resources/PageResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static function form(Form $form): Form
->maxLength(191),
Forms\Components\TextInput::make('slug')
->required()
->unique(ignoreRecord: true)
->maxLength(191),
Forms\Components\RichEditor::make('body')
->required()
Expand Down
1 change: 1 addition & 0 deletions app/Filament/Resources/PostResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static function form(Form $form): Form
->maxLength(191),
Forms\Components\TextInput::make('slug')
->required()
->unique(ignoreRecord: true)
->maxLength(191),
Forms\Components\RichEditor::make('body')
->required()
Expand Down
1 change: 1 addition & 0 deletions app/Filament/Resources/SettingResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static function form(Form $form): Form
->schema([
Forms\Components\TextInput::make('key')
->required()
->unique(ignoreRecord: true)
->maxLength(191),
Forms\Components\TextInput::make('display_name')
->required()
Expand Down

0 comments on commit 3c289ef

Please sign in to comment.