Vinelab / NeoEloquent

The Neo4j OGM for Laravel
MIT License
634 stars 200 forks source link

"orderBy" not working with relationships? #151

Closed emredoganm closed 8 years ago

emredoganm commented 8 years ago

I have a relationship between two users like below: public function friends(){ return $this->belongsToMany("App\Models\User",Config::get('relations.user_to_user')); }

and with this relationship I want to use a query like this : $user->friends()->orderBy("first_name","ASC")->get() but I get same result. I think in relationships "orderBy" not working. I got no error.

KinaneD commented 8 years ago

Which version are you using?

emredoganm commented 8 years ago

My Laravel version is 5.1 and NeoEloquent version is 1.3.0

KinaneD commented 8 years ago

is the relationship method name you use to define it a composite name like fictionBooks() for instance? or is it a simple one like books() or fiction()?

emredoganm commented 8 years ago

Simple one. I am using friends()...

KinaneD commented 8 years ago

Since it is a relationships between nodes of the same Model class you should use hasMany instead of belongsToMany. This should solve it.