First try upgrading to 2.7. It was released 2 days ago.
If that don't work, you should make a bug report here https://github.com/laravel/nova-issues/issues
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello ! Here I come again with a strange behavior. I'm trying to use the relatable query Nova feature to restrict the colors (from my Color model) shown in my BelongsTo dropdown, but I struck a huge... bug ?
First of all, here's a code snippet pulled from Nova's documentation of what I'm trying to accomplish :
public static function relatableTags(NovaRequest $request, $query)
{
$resource = $request->route('resource'); // Returns the resource type.
$resourceId = $request->route('resourceId'); // Returns the resource id.
return $query->where('type', $resource);
}
Here's my relatable query :
public static function relatableColors(NovaRequest $request, $query)
{
$resourceId = $request->route('resourceId');
return $query->whereHas('zones', function($query) use ($resourceId) {
$query->where('zone_id', $resourceId);
});
}
So here's the issue : I'm supposed to receive all colors with a zones relation having the current zone ID (contained in $request->route('resourceId')), but no color option is found inside the select.
In my debug case, $resourceId contained a string of "2" (inside the subquery). I told myself that maybe I would get something by casting it to an int... nothing. I then replaced it with an hardcoded 2 (int). Success ! Wait what ? I just casted a string of "2" to an int and it didn't work beforehand. Why ?
I pushed my debug case further. I started by hardcoding a string of "2" instead of an integer, inside a variable placed outside of my subquery. It also worked. Same thing when I casted my hardcoded "2" string to float. Weird...
I then pushed it to an other level (an ugly level if you ask me). I created an anonymous function variable which returned the int casted value of $request->route('resourceId'). No success. I then changed the anonymous function to increment a variable with the help of a loop while the variable was smaller than $request->route('resourceId') (it's big brain time !!!). No success again...
I also tried integer multiplications, additions and substractions on my $request->route('resourceId') variable. No luck...
Can someone give me explanations ? I'm kinda out of ideas.
Please or to participate in this conversation.