© 2026 Hedgehog Software, LLC

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

Builder query for polymorphic relations

I would like to create a custom filter with a custom query as shown below. The query needs to follow the
payable
payable
polymorphic relationship on the active record and on that relationship check if the
consulable_type
consulable_type
is of a specific class.


Tables\Filters\Filter::make('consult')
    ->query(
        function (Builder $query) {
            return $query->whereHas('payable', function ($query) {
                $query->where('consultable_type', '=', WardConsult::class);
            });
        }
    ),

Tables\Filters\Filter::make('consult')
    ->query(
        function (Builder $query) {
            return $query->whereHas('payable', function ($query) {
                $query->where('consultable_type', '=', WardConsult::class);
            });
        }
    ),


When activating this filter, I get the error:
Class "App\Models\Unknown" not found
Class "App\Models\Unknown" not found
. Does anyone know an active example or could help me fix this code?

TIA!
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

Form Builder support for polymorphic relationships
FilamentFFilament / ❓┊help
2y ago
Polymorphic relations in filament
FilamentFFilament / ❓┊help
3y ago
Cascading/conditional form on polymorphic relations?
FilamentFFilament / ❓┊help
17mo ago
Convert Eloquent relationship to query builder for table?
FilamentFFilament / ❓┊help
3y ago