1. Go to this page and download the library: Download itbm/laravel-likeable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use Cog\Likeable\Contracts\Likeable as LikeableContract;
use Cog\Likeable\Traits\Likeable;
use Illuminate\Database\Eloquent\Model;
class Article extends Model implements LikeableContract
{
use Likeable;
}
$article->like(); // current user
$article->like($user->id);
$article->unlike(); // current user
$article->unlike($user->id);
$article->likeToggle(); // current user
$article->likeToggle($user->id);
$article->likesCount;
$article->likesCounter;
$article->likes();
$article->likes;
$article->liked; // current user
$article->liked(); // current user
$article->liked($user->id);
$article->collectLikers();
$article->removeLikes();
$article->dislike(); // current user
$article->dislike($user->id);
$article->undislike(); // current user
$article->undislike($user->id);
$article->dislikeToggle(); // current user
$article->dislikeToggle($user->id);
$article->dislikesCount;
$article->dislikesCounter;
$article->dislikes();
$article->dislikes;
$article->disliked; // current user
$article->disliked(); // current user
$article->disliked($user->id);