diff --git a/app/Filament/Central/Resources/CompanyResource.php b/app/Filament/Central/Resources/CompanyResource.php index d6d4208..ac31c60 100644 --- a/app/Filament/Central/Resources/CompanyResource.php +++ b/app/Filament/Central/Resources/CompanyResource.php @@ -35,7 +35,10 @@ class CompanyResource extends Resource ->required() ->alphaDash() ->maxLength(30) - ->unique(ignoreRecord: true) + ->unique( + ignoreRecord: true, + modifyRuleUsing: fn ($rule) => $rule->whereNull('deleted_at'), + ) ->dehydrateStateUsing(fn ($state) => strtolower((string) $state)) ->extraInputAttributes(['style' => 'text-transform: lowercase']) ->helperText('Subdomeniul: .service.mir.md'), diff --git a/database/migrations/2026_05_07_000001_drop_companies_slug_unique.php b/database/migrations/2026_05_07_000001_drop_companies_slug_unique.php new file mode 100644 index 0000000..c994497 --- /dev/null +++ b/database/migrations/2026_05_07_000001_drop_companies_slug_unique.php @@ -0,0 +1,30 @@ +dropUnique('companies_slug_unique'); } catch (\Throwable $e) {} + $t->index('slug', 'companies_slug_index'); + }); + } + + public function down(): void + { + Schema::table('companies', function (Blueprint $t) { + try { $t->dropIndex('companies_slug_index'); } catch (\Throwable $e) {} + $t->unique('slug', 'companies_slug_unique'); + }); + } +};