diff --git a/src/Filament/Resources/PageResource.php b/src/Filament/Resources/PageResource.php index 47413e9..f0b7643 100644 --- a/src/Filament/Resources/PageResource.php +++ b/src/Filament/Resources/PageResource.php @@ -18,6 +18,7 @@ use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\MultiSelectFilter; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; use LaraZeus\Sky\Filament\Resources\PageResource\Pages; use LaraZeus\Sky\Models\Post; @@ -77,6 +78,7 @@ public static function form(Form $form): Form ->hint(__('Write an excerpt for your post')), TextInput::make('slug') + ->unique(ignorable: fn (?Model $record): ?Model => $record) ->required() ->maxLength(255) ->label(__('Post Slug')), diff --git a/src/Filament/Resources/PostResource.php b/src/Filament/Resources/PostResource.php index 7027724..a1bc0f2 100644 --- a/src/Filament/Resources/PostResource.php +++ b/src/Filament/Resources/PostResource.php @@ -20,6 +20,7 @@ use Filament\Tables\Filters\Filter; use Filament\Tables\Filters\MultiSelectFilter; use Illuminate\Database\Eloquent\Builder; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; use LaraZeus\Sky\Filament\Resources\PostResource\Pages; use LaraZeus\Sky\Models\Post; @@ -77,6 +78,7 @@ public static function form(Form $form): Form ->hint(__('Write an excerpt for your post')), TextInput::make('slug') + ->unique(ignorable: fn (?Model $record): ?Model => $record) ->required() ->maxLength(255) ->label(__('Post Slug')), diff --git a/src/Filament/Resources/TagResource.php b/src/Filament/Resources/TagResource.php index 5dbfc02..ed74d23 100644 --- a/src/Filament/Resources/TagResource.php +++ b/src/Filament/Resources/TagResource.php @@ -8,6 +8,7 @@ use Filament\Resources\Form; use Filament\Resources\Table; use Filament\Tables\Columns\TextColumn; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Str; use LaraZeus\Sky\Filament\Resources\TagResource\Pages; use LaraZeus\Sky\Models\Tag; @@ -43,6 +44,7 @@ public static function form(Form $form): Form $set('slug', Str::slug($state)); }), TextInput::make('slug') + ->unique(ignorable: fn (?Model $record): ?Model => $record) ->required() ->maxLength(255), Select::make('type')