A view and like counter extension for Eloquent models
Via Composer
$ composer require ashishov/laravel-eloquent-counter
Add the service provider in app/config/app.php
:
Ashishov\EloquentCounter\ServiceProvider::class,
php artisan vendor:publish
Now you can migrate:
php artisan migrate
class Object extends Eloquent {
use Ashishov\EloquentCounter\Countable;
}
$object->view();
**Get count of Views
$object->views_count();
**Did the user viewed the object?
$object->isViewed();
**Increment the LikeCounter in a Controller (show action)
$object->like();
**Unlike
$object->unlike();
**Get count of Likes
$object->likes_count();
**Did the user liked the object?
$object->isLiked();
The MIT License (MIT). Please see License File for more information.