BKWLD / decoy

A Laravel model-based CMS
http://docs.decoy.bukwild.com/
MIT License
303 stars 44 forks source link

Bug in "Pivot-Position-Sorting" with Laravel 5.4 #73

Closed arminulrich closed 7 years ago

arminulrich commented 7 years ago

Hello!

I tried to add sorting of a ManyToMany Relationship (like http://docs.decoy.bukwild.com/models#relationships)

But it throws an error because of /vendor/bkwld/decoy/classes/Input/Position.php:30 - 'getOtherKey' ... this method was moved onto the Pivot Object in Laravel 5.4.

Did a quick fix by requesting the first child and taking the otherKeyfrom its pivot.. $this->pivot = $relation->where($relation->first()->pivot->getOtherKey(), '=', request('parent_id'))->first()->pivot;

At this point we should always have one related item so this works for me :P

..

Actually i'm not sure if you're supporting Laravel 5.4 officially. But other than this issue everything runs perfect :)

weotch commented 7 years ago

Yeah, Laravel 5.4 is supported (despite this bug 😅). Do you wanna PR the fix you found?

Looks like we need to add sorting of many to many relationships to the tests...

weotch commented 7 years ago

Closed by #74