Querying relations with extra conditions in Eager Loading not working
tisuchi opened this issue · 6 comments
tisuchi commented
My regular data fetching issue has been solved by this issue.
But when I need to fetch this relationship in eager loading, it always return null.
For example-
public function allMatches()
{
return $this->hasMany('Match', 'visitant_id')->orWhere('local_id', $this->id);
}
If I need to fetch with()
method, its not working.
$team = Team::where('id', 2)->with('allMatches')->first();
Dylan-DPC-zz commented
your relation is defined wrongly
tisuchi commented
@Dylan-DPC
Haha. I believe, you didn't read the whole things. Take a look very carefully before submitting your comment again that, @taylorotwell gave this solution here...
#1272
I M NOT WRONG. I just follow him.
themsaid commented
its not working.
More details please, what's the laravel version you use?
themsaid commented
Closing for lack of activity.
tisuchi commented
I am using laravel 5.2
topclaudy commented
@tisuchi For laravel 5.4 or greater, you may use https://github.com/topclaudy/compoships to solve this issue.