Interesting!
What would be a real world example that this would be used in?
An example can be a Blog or news site:
You can show a box with "Top posts": Most popular posts, Yesterday most read posts, Last week most popular posts, All time most popular posts, all of them ordered by the number of views each post has had in each period of time.
e.g.: https://www.dailyherald.com/section/mostread/ Most Viewed right sidebar box
Or instead of showing top post links, you can paginate and order all of your post by some of the available date ranges, and have a menu in your site with: Yesterday most popular posts, etc
e.g. https://www.dailyherald.com/section/mostread/ Today's most viewed main content
This is great, will try it in the next days.
Idea for a function, maybe already possible?
Thanks for the idea, If I understood it right that is already possible. The main function https://github.com/marcanuy/popularity/blob/master/src/Marcanuy/Popularity/Popularity.php#L15 can filter its results by any of the saved data fields in the Popularity model: available time ranges, Eloquent model name, etc, but as the returned result is an instance of
\Illuminate\Database\Eloquent\Builder
you can add your own filters too, and then get the results paginated or process them in any way.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community