rtconner / laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a "like" or "favorite" or "remember" feature.
MIT License
401 stars 49 forks source link

Best way to orderBy likes? #32

Closed robertem128 closed 7 years ago

robertem128 commented 7 years ago

Hi,

I didn't see anything in the docs about ordering posts by like count so I thought I'd ask.

Currently, i'm using

->withCount('likes')
->orderBy('likes_count', 'desc')

Is this the recommended way?

Thanks

rtconner commented 7 years ago

That seems correct

robertem128 commented 7 years ago

Great. Thanks for your work on this, it was very helpful in my project.

ismailcaakir commented 7 years ago

Thanks, this works really well.