LaravelPackages.net
Acme Inc.
Toggle sidebar
sweeeeep/l5popularity

Laravel Package for Tracking popular item in Eloquent models

86
2
1.1.0
About sweeeeep/l5popularity

sweeeeep/l5popularity is a Laravel package for laravel package for tracking popular item in eloquent models. It currently has 2 GitHub stars and 86 downloads on Packagist (latest version 1.1.0). Install it with composer require sweeeeep/l5popularity. Discover more Laravel packages by sweeeeep or browse all Laravel packages to compare alternatives.

Last updated

Laravel 5 Popularity

Based on marcanuy/popularity

Latest Version on Packagist Total Downloads Build Status StyleCI

This is where your description should go. Take a look at contributing.md to see a to do list.

Installation

Via Composer

$ composer require sweeeeep/l5popularity

Updating your Eloquent Models

Your model should use the Popularable traits, which has method hit() that you need use

  <?php
  
    use Sweeeeep\Popularity\Popularable;
    
    class Post extends Model
    {
      use Popularable;
      
    }

Usage

It makes use of Eloquent's polymorphic relations , so each tracked model has its own stats.

Tracking Hits

For each model instance that has already been saved into the db (or already has an id), call hit() method to increase count for each time frame, e.g. in routes.php each time a post or an article is viewed, or an Eloquent event is fired.

$post = Post::find(1);
$post->hit();

Change log

Please see the changelog for more information on what has changed recently.

Contributing

Please see contributing.md for details and a todolist.

License

license. Please see the license file for more information.

Star History Chart