Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Querying relations with extra conditions in Eager Loading not working #19488

Closed
tisuchi opened this issue Jun 6, 2017 · 6 comments
Closed

Querying relations with extra conditions in Eager Loading not working #19488

tisuchi opened this issue Jun 6, 2017 · 6 comments

Comments

@tisuchi
Copy link
Contributor

tisuchi commented Jun 6, 2017

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
Copy link

your relation is defined wrongly

@tisuchi
Copy link
Contributor Author

tisuchi commented Jun 7, 2017

@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
Copy link
Member

themsaid commented Jun 7, 2017

its not working.

More details please, what's the laravel version you use?

@themsaid
Copy link
Member

Closing for lack of activity.

@tisuchi
Copy link
Contributor Author

tisuchi commented Jun 14, 2017

I am using laravel 5.2

@topclaudy
Copy link

@tisuchi For laravel 5.4 or greater, you may use https://github.com/topclaudy/compoships to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants