Support the ongoing development of Laravel.io →
posted 9 years ago
Eloquent
Last updated 2 years ago.
0

You are calling a function (query builder) on your relationships. You really need to just...

Step::find(1)->connections->connectionSteps;

Laravel does the magic behind the scenes.

I can't remeber of the top of my head, but if you want to use the current code you have, add ->get() to the end and that should work.

Step::find(1)->connections()->connectionSteps()->get();

Hope it helps.

Last updated 2 years ago.
0

You could use eager loading aswell, I find this helpful when I want to load more than one relationship.

Step::with('connections')->where('id', 1)->get();

Eager Loading Documentation

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

glopz glopz Joined 24 Oct 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.