renoki-co / befriended

Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Most liked posts?

daltonsutton opened this issue · comments

How would I go about getting the most liked posts? I've tried a few different queries but couldn't get anything working correctly. Thanks in advance for any help!

This query could start you in the right direction. Returns the post_id with associated number of likes - most liked first.

SELECT
    `likeable_id` AS post_id,
    COUNT(*) AS n_likes
FROM
    `likers`
WHERE
    `likeable_type` LIKE '%Post'
GROUP BY
    `likeable_id`
ORDER BY
    n_likes
DESC
commented

This issue has been automatically closed because it has not had any recent activity. 😨