thedevdojo / chatter

Chatter is a Simple Laravel Forum Package
https://devdojo.com/forums
MIT License
900 stars 294 forks source link

Posts ordering not working #203

Closed terdia closed 6 years ago

terdia commented 6 years ago

I notice that when I set order by posts to descending order it had no effect my config 'order_by' => [ 'posts' => [ 'order' => 'created_at', 'by' => 'DESC' ], 'discussions' => [ 'order' => 'last_reply_at', 'by' => 'DESC' ] ],

Then I did a little digging and found a bug in ChatterController.php $discussions = Models::discussion()->with('user')->with('post')->with('postsCount')->with('category')->orderBy(config('chatter.order_by.discussions.order'), config('chatter.order_by.discussions.by'));

using order by config('chatter.order_by.discussions.order') twice I have created a pull request with the fix https://github.com/thedevdojo/chatter/pull/202

marktopper commented 6 years ago

discussions.order is how the list of discussions will be ordered while posts.order is how the individual posts inside a discussion are ordered.

terdia commented 6 years ago

@marktopper I understand that but it doesn't work because in the source code you only order by discussions (twice)