Answer the question
In order to leave comments, you need to log in
How to display user rating in laravel?
Hello! It is necessary to display the top 50 users per month, for all time, on a separate page. As in a separate category, and for all categories.
And now in more detail.
The site is still under development, for me this is the first project on laravel. Therefore, I ask for help from Toaster users, not necessarily with code, you can simply paint the logic. I can't even imagine how to implement this feature.
Each user (table users) has his own news (table news), which he adds daily. After checking by the administration, each news is assigned a number in the status field. If 1, then the user is given a rating of +50. If 2, then -30. If 3, then the rating does not change.
It is necessary to display the top users for the month and for all time, in each category (table categories) and in all categories together.
How to carry out this rating? Help with rating logic. And if you also throw the code, I will be immensely grateful.
Answer the question
In order to leave comments, you need to log in
MySQL query
select
`id_user`
,sum(case when `status` = 1 then 50 else 0 end) - sum(case when `status` = 2 then 30 else 0 end)
from news
WHERE MONTH(`date`) = 3 AND YEAR(`date`) = 2019
group by 1
order by 2 desc, 1 asc
LIMIT 50
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question