Support the ongoing development of Laravel.io →
Database Eloquent Packages
Last updated 2 years ago.
0

Interesting!

What would be a real world example that this would be used in?

Last updated 2 years ago.
0

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

Last updated 2 years ago.
0

This is great, will try it in the next days.

Idea for a function, maybe already possible?

  • I fetch my items based on my own filters (eg. category, searchterm ...) and call a function on it to sort them by the polularity stats by day, week, month ...
Last updated 2 years ago.
0

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.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

marcanuy marcanuy Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.