whereHas() query doesn't accept variables when filtering.
So here's my code:
The problem is in the
$query?->where('project_stage_id', $stage->id);
.
When entering a static number in the $stage->id, it works.
But when I input the variable (I know it's working, because in the PlaceholderTest it shows it correctly) it just shows all the subpoints from the last stage.
This is a ManyToMany relationship. The main $record
has a HasMany
relationship called projectSubpoints
and in that pivot model, it has the link to the subpoints called projectStageSubpoint
.0 Replies