jacobcyl/laravel-counter

view and like counter
681 1
Install
composer require jacobcyl/laravel-counter
Latest Version:2.1.4
License:MIT
Last Updated:Jun 3, 2016
Links: GitHub  ·  Packagist
Maintainer: jacobcyl

Installation

composer require jacobcyl/view-counter:^2.0

Configuration

add provider

    Jacobcyl\ViewCounter\ViewCounterServiceProvider::class,

publish config file and migration files

    php artisan vendor:publish 
    php artisan migrate

add "use ViewCounterTrait;" to your model

    $model->view()

##add schedule task edit app/Console/Kernel.php file's schedule method.add counter:sync command:

    protected function schedule(Schedule $schedule)
    {
        $schedule->command('counter:sync')->dailyAt('23:50');
    }

run crontab -e then add follow

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1

##command synchronize data to the database

php artisan counter:sync

initialize view counter of specified model

php artisan counter:view product 100 --action=plus // the specified product increased by 100 views

Related Packages

cyrildewit/eloquent-viewable

Laravel package that allows you to associate views with Eloquent models

1,191,682 885
awssat/laravel-visits

Laravel Redis visits counter for Eloquent models

173,979 973
edvinaskrucas/counter-laravel

Counter library integration into laravel framework.

72 0
cjjian/visitors

log your visitors in db, page hits, and generate visit counter for Laravel 5

23 2
php-tmdb/laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the...

53,303 162