PHPackages                             combindma/laravel-popularity - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. combindma/laravel-popularity

ActiveLibrary

combindma/laravel-popularity
============================

A Laravel package for tracking popular entries(by Models) of a website in a certain time

1.3.0(1y ago)0256MITPHPPHP ^8.3CI passing

Since Sep 22Pushed 1y agoCompare

[ Source](https://github.com/combindma/laravel-popularity)[ Packagist](https://packagist.org/packages/combindma/laravel-popularity)[ Docs](https://github.com/combindma/laravel-popularity)[ RSS](/packages/combindma-laravel-popularity/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (12)Versions (6)Used By (0)

A Laravel package for tracking popular entries(by Models) of a website in a certain time
========================================================================================

[](#a-laravel-package-for-tracking-popular-entriesby-models-of-a-website-in-a-certain-time)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9073ef0d70da7b2b8f1c76a54e99d3f2bc5b0ebbba02412e187caff8b0727fb9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6d62696e646d612f6c61726176656c2d706f70756c61726974792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/combindma/laravel-popularity)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ac00f1400bb9b387e743e1e6f8a9413e9a66c095550e5a50f1001408b5ea2ec2/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6d62696e646d612f6c61726176656c2d706f70756c61726974792f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/combindma/laravel-popularity/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/cd1482bd7f2bc1a5f82a9e633c585b2a5d8cf2e0d25d964ae02767619284fcae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f6d62696e646d612f6c61726176656c2d706f70756c61726974792f466978253230504850253230636f64652532307374796c652532306973737565733f6c6162656c3d636f64652532307374796c65)](https://github.com/combindma/laravel-popularity/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6da8a1d2c2c1b7ec35db28780c134b7f512f4f08e10ba5730a3bb9cf77af3821/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6d62696e646d612f6c61726176656c2d706f70756c61726974792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/combindma/laravel-popularity)

With Laravel Popularity Package you can Track your most popular Eloquent Models based on unique hits in a time range and then sort by popularity in a time frame.With Laravel Popular Package you can Track your most popular Eloquent Models based on unique hits in a time range and then sort by popularity in a time frame.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require combindma/laravel-popularity
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="popularity-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

Use the visitable trait on the model you intend to track

```
use Combindma\Popularity\Traits\Visitable;

class Page extends Model
{
    use Visitable;

    ...
}
```

This is how you create a visit (visits are not duplicated for a daily timeframe):

```
// Adding a visit to the page.
$page->visit();

// Adding a visit to the page with ip address.
$page->visit()->withIp();

// Adding a visit with the given ip address.
$page->visit()->withIp('my-ip-address');

// Adding a visit with custom data.
$page->visit()->withData(['item' => 'value']);

// Adding a visit with logged user.
$page->visit()->withUser();

// Adding a visit with the given user.
$page->visit()->withUser($userId);

// Adding a visit with all above methods.
$page->visit()->withIp()->withUser()->withData(['item' => 'value']);
```

Changing the timeframe for creating visits with the same data:

```
// creates visits after hourly timeframe
$page->hourlyInterval()->withIp();

// creates visits after a daily timeframe
$page->dailyInterval()->withIp();

// creates visits after a weekly timeframe
$page->weeklyInterval()->withIp();

// creates visits after a monthly timeframe
$page->monthlyInterval()->withIp();
```

Getting the records by the most visited

```
// gets the total visit count
$page = Page::withTotalVisitCount()->first();
return $page->visit_count_total;

// gets records by all time popularity
$pages = Page::popularAlltime()->get();
return $pages->first()->visit_count_total;

// gets popular records between two dates
$pages = Page::popularBetween(Carbon::createFromDate(1990, 12, 01), Carbon::createFromDate(1990, 12, 04))->get();
return $pages->first()->visit_count;

// gets popular records by the last x days
$pages = Page::popularLastDays(2)->get();
retutn $pages->first()->visit_count;

// gets popular records by the last week
$pages = Page::popularLastWeek()->get();
return $pages->first()->visit_count;

// gets popular records by this week
$pages = Page::popularThisWeek()->get();
return $pages->first()->visit_count;

// gets popular records by the last month
$pages = Page::popularLastMonth()->get();
return $pages->first()->visit_count;

// gets popular records by this month
$pages = Page::popularThisMonth()->get();
return $pages->first()->visit_count;

// gets popular records by this year
$pages = Page::popularThisYear()->get();
return $pages->first()->visit_count;
```

Testing
-------

[](#testing)

```
composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Combind](https://github.com/combindma)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance45

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~224 days

Total

5

Last Release

430d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.3.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/31b418bcbabafab33631fd151a64d3e18035f728ad195814aa4656d862610fcd?d=identicon)[combindma](/maintainers/combindma)

---

Top Contributors

[![omarherri](https://avatars.githubusercontent.com/u/12627384?v=4)](https://github.com/omarherri "omarherri (1 commits)")

---

Tags

laravelcombindmalaravel-popularity

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/combindma-laravel-popularity/health.svg)

```
[![Health](https://phpackages.com/badges/combindma-laravel-popularity/health.svg)](https://phpackages.com/packages/combindma-laravel-popularity)
```

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
