© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
12 replies
BlackShadow

Custom Validation with relation

->rules([function ($record) {
    return function (string $attribute, $value, Closure $fail) use ($record) {
      if (Model::where('agreement_id', $replaceWithRelationID)->whereDate('start_date', '>=', $value)->exists()) {
        $fail("There is already a price agreement right/after this date");
      }
    };
}]),
->rules([function ($record) {
    return function (string $attribute, $value, Closure $fail) use ($record) {
      if (Model::where('agreement_id', $replaceWithRelationID)->whereDate('start_date', '>=', $value)->exists()) {
        $fail("There is already a price agreement right/after this date");
      }
    };
}]),


I need to replace
replaceWithRelationID
replaceWithRelationID
with the parameter ID from the url or the relationship its on.
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

Custom validation with HTML
FilamentFFilament / ❓┊help
3y ago
Validation from relation managers
FilamentFFilament / ❓┊help
2y ago
Custom Validation
FilamentFFilament / ❓┊help
3y ago
Custom validation rules
FilamentFFilament / ❓┊help
3y ago