Require this package, with Composer, in the root directory of your project.
$ composer require artisanry/likeableTo get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="Artisanry\Likeable\LikeableServiceProvider" && php artisan migrate
<?php
namespace App;
use Artisanry\Likeable\HasLikesTrait;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasLikesTrait;
}$post->like($user);$post->dislike($user);$post->likeCount;$post->likes;$post->liked($user);Post::whereLiked($user)->get();$post->getLikeCount();$post->getLikeCountByDate('2015-06-30');$post->getLikeCountByDate('2015-06-30', '2015-06-31');$ phpunitIf you discover a security vulnerability within this package, please send an e-mail to hello@basecode.sh. All security vulnerabilities will be promptly addressed.
This project exists thanks to all the people who contribute.
Mozilla Public License Version 2.0 (MPL-2.0).