Skip to content

Commit eddb78a

Browse files
feat: [LAR-34] add unique condition to input name with message and remove unnecessary test
1 parent d993ba8 commit eddb78a

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

app/Filament/Resources/TagResource.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ public static function form(Form $form): Form
2626
return $form
2727
->schema([
2828
Forms\Components\TextInput::make('name')
29-
->required()
3029
->live(onBlur: true)
30+
->required()
31+
->unique()
32+
->validationMessages([
33+
'unique' => 'Cette valeur existe déjà',
34+
])
3135
->afterStateUpdated(function (string $operation, $state, Forms\Set $set): void {
3236
$set('slug', Str::slug($state));
3337
})

tests/Feature/Filament/TagTest.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,26 +52,6 @@
5252
->assertStatus(200);
5353
});
5454

55-
it('Generate tag if tag already exist', function (): void {
56-
57-
$name = fake()->name();
58-
Tag::factory()->create([
59-
'name' => $name,
60-
'slug' => Str::slug($name),
61-
'concerns' => ['discussion'],
62-
]);
63-
64-
Livewire::test(ListTags::class)
65-
->callAction(CreateAction::class, data: [
66-
'name' => $name,
67-
'concerns' => ['post', 'tutorial'],
68-
'description' => 'Description du tag '.$name,
69-
]);
70-
71-
expect(Tag::orderByDesc('id')->first()->slug)
72-
->toBe(Str::slug($name).'-1');
73-
});
74-
7555
it('Admin can edit tag', function (): void {
7656
$tag = Tag::factory()->create();
7757

0 commit comments

Comments
 (0)