File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,7 +53,17 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
5353 ->createOptionForm ([
5454 \Filament \Forms \Components \TextInput::make ('name ' )
5555 ->required ()
56- ->maxLength (255 ),
56+ ->maxLength (255 )
57+ ->rules ([
58+ function ($ attribute , $ value , $ fail ) {
59+ $ slug = \Illuminate \Support \Str::slug ($ value );
60+ $ existingTag = \Tapp \FilamentLibrary \Models \LibraryItemTag::where ('slug ' , $ slug )->first ();
61+
62+ if ($ existingTag ) {
63+ $ fail ('A tag with this name already exists. ' );
64+ }
65+ },
66+ ]),
5767 ])
5868 ->createOptionUsing (function (array $ data ): int {
5969 $ tag = \Tapp \FilamentLibrary \Models \LibraryItemTag::create ([
Original file line number Diff line number Diff line change @@ -37,7 +37,17 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
3737 ->createOptionForm ([
3838 \Filament \Forms \Components \TextInput::make ('name ' )
3939 ->required ()
40- ->maxLength (255 ),
40+ ->maxLength (255 )
41+ ->rules ([
42+ function ($ attribute , $ value , $ fail ) {
43+ $ slug = \Illuminate \Support \Str::slug ($ value );
44+ $ existingTag = \Tapp \FilamentLibrary \Models \LibraryItemTag::where ('slug ' , $ slug )->first ();
45+
46+ if ($ existingTag ) {
47+ $ fail ('A tag with this name already exists. ' );
48+ }
49+ },
50+ ]),
4151 ])
4252 ->createOptionUsing (function (array $ data ): int {
4353 $ tag = \Tapp \FilamentLibrary \Models \LibraryItemTag::create ([
Original file line number Diff line number Diff line change @@ -41,7 +41,17 @@ public function form(\Filament\Schemas\Schema $schema): \Filament\Schemas\Schema
4141 ->createOptionForm ([
4242 \Filament \Forms \Components \TextInput::make ('name ' )
4343 ->required ()
44- ->maxLength (255 ),
44+ ->maxLength (255 )
45+ ->rules ([
46+ function ($ attribute , $ value , $ fail ) {
47+ $ slug = \Illuminate \Support \Str::slug ($ value );
48+ $ existingTag = \Tapp \FilamentLibrary \Models \LibraryItemTag::where ('slug ' , $ slug )->first ();
49+
50+ if ($ existingTag ) {
51+ $ fail ('A tag with this name already exists. ' );
52+ }
53+ },
54+ ]),
4555 ])
4656 ->createOptionUsing (function (array $ data ): int {
4757 $ tag = \Tapp \FilamentLibrary \Models \LibraryItemTag::create ([
You can’t perform that action at this time.
0 commit comments