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
polymorphic relationship on the active record and on that relationship check if the 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);
});
}
),
When activating this filter, I get the error: Class "App\Models\Unknown" not found
. Does anyone know an active example or could help me fix this code?
TIA!1 Reply
Bumping the question!