I'm not 100% sure, but why not add the where condition next to the belongsTo?
return $this->belongsTo(Human::class)->whereSexId(1);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi Everybody!
New, old problem. How to filter BelongsTo relation? I have relation:
public function mom()
{
return $this->belongsTo(Human::class);
}
When trying to choose mom it shows me tousands records, does not matter of sex.
I want to see only records from 'humans' table with 'sex_id' = 1
I reached the end of Internet and back, I could not fine any working solution.
Any help?
Please or to participate in this conversation.