© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Ibon Azkoitia

ignoreRecord for TextColumn with different slugs for each domain

Hello! I'm fighting for hours with this and maybe just your experience can help me in minutes.

The situation

Users should be able to create custom links for different domains.

Model 1 = Domain
Model 2 = Link (with column for the 'slug')

Different domains should be able to have same slug:

domain1/slugxyz
domain2/slugxyz

So I created a custom Rule at that input on the Form.

 ->rules([
    fn (Get $get): Closure => function(string $attribute, mixed $value, Closure $fail) use ($get): bool {
        $slugInDomain = Link::where('domain_id', $get('domain_id'))
            ->where('slug', '=', $value)
            ->first();

        if ( $slugInDomain ) {
            $fail("The slug is already in use.");
        }

        return true;
    }
])
 ->rules([
    fn (Get $get): Closure => function(string $attribute, mixed $value, Closure $fail) use ($get): bool {
        $slugInDomain = Link::where('domain_id', $get('domain_id'))
            ->where('slug', '=', $value)
            ->first();

        if ( $slugInDomain ) {
            $fail("The slug is already in use.");
        }

        return true;
    }
])


It gets the domain_id from the Select field with the ->live() option.

The goal check if a Link for that Domain with that slug exists. If not, continue. If yes, give error

The problem: when trying to edit a record, it says it already exists

I tried the option ->unique(ignoreRecord: true). But, as i should be able to have same slug for different domains (but just 1 for each domain), i didn't manage to make it work.

Thank you!
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

TextColumn List with URL on each item
FilamentFFilament / ❓┊help
2y ago
ignoreRecord: true
FilamentFFilament / ❓┊help
3y ago
Different app name for each panel
FilamentFFilament / ❓┊help
3y ago
How to put a link for each badge in TextColumn?
FilamentFFilament / ❓┊help
3y ago