view and like counter

2.1.4 2016-06-03 09:13 UTC

This package is not auto-updated.

Last update: 2022-05-09 01:41:46 UTC


composer require jacobcyl/view-counter:^2.0


add provider


publish config file and migration files

    php artisan vendor:publish 
    php artisan migrate

add "use ViewCounterTrait;" to your model


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

    protected function schedule(Schedule $schedule)

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