You can use the HasLikes trait in as many Models as you want!
How to like and dislike
The example above will automaticly associate the currently logged in userauth()->user() to the like/dislike.
If you want to associate another user, just pass his ID through the like() or dislike() method:
$user=User::where('email', 'email@example.com')->first();// Like$post->like($user->id);// or dislike$post->like($user->id);
Count total likes or dislikes
// Count total likes for this post$post->likeCount();// or count total dislikes$post->dislikeCount();
Lets imagine, you want have two models, with like functionality: Post and Comment.