using var as relationship name

Posted 2 years ago by zaidk26

Hi, my related model is eager loaded . if I use $parent->child->count() , it works fine. I need to use a var so i'm trying $parent->$child->count() , this works, but instead of just giving me the count because its already eager loaded . it goes and runs a db query . how do you use a var to access it ?

Please sign in or create an account to participate in this conversation.