© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
bernhard

Unique and RelationManagers

I have a relation manager for my RecipeResource. The Relationamanager has itself a form, with a Datepicker field:

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make("name"),
                DatePicker::make("published_at")
                    ->unique(callback: function(Unique $rule) {
                        return $rule
                            ->where("recipe_id", "XXX");
                    })
                    ->default(now())
                    ->required()
            ]);
    }
    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make("name"),
                DatePicker::make("published_at")
                    ->unique(callback: function(Unique $rule) {
                        return $rule
                            ->where("recipe_id", "XXX");
                    })
                    ->default(now())
                    ->required()
            ]);
    }


The date should be unique within the Recipe. How do I get the
recipe_id
recipe_id
inside the unique callback (the
XXX
XXX
in the code)?
As far as I understand is
$rule
$rule
the only param for the callback.
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

RelationManagers ERROR
FilamentFFilament / ❓┊help
3y ago
New relationmanagers not registering?
FilamentFFilament / ❓┊help
2y ago
unique() and disabled()
FilamentFFilament / ❓┊help
2y ago
Editing RelationManagers on View Resource
FilamentFFilament / ❓┊help
3y ago