Manage Friendships, Likes and More with the Acquaintances Laravel Package


May 29th, 2020


The multicaret/laravel-acquaintances package gives eloquent models the ability to manage friendships, groups, followers, likes, ratings, and favorites.

Related: Add Social Reactions to Model with Laravel Love

Here’s a basic example from the readme:

1$user1 = User::find(1);
2$user2 = User::find(2);
7// The messy breakup :(

Out of the box, you can expect the following features (features may change over time):

  • Send Friend Requests
  • Accept Friend Requests
  • Deny Friend Requests
  • Block a User
  • Group Friends
  • Rate a User or a Model, supporting multiple aspects
  • Follow a User or a Model
  • Like a User or a Model
  • Subscribe a User or a Model
  • Favorite a User or a Model
  • Vote (Upvote & Downvote a User or a Model)

The package has several traits you can use to define capabilities on a model. Here’s a bunch of them defined on a User model:

1use Multicaret\Acquaintances\Traits\CanBeFollowed;
2use Multicaret\Acquaintances\Traits\CanFollow;
3use Multicaret\Acquaintances\Traits\CanLike;
4use Multicaret\Acquaintances\Traits\Friendable;
7class User extends Model
9 use Friendable;
10 use CanLike;
11 use CanFollow, CanBeFollowed;
12 use CanRate, CanBeRated;
13 //...

The project’s readme has all the details for each model interaction and contains quite a few useful features. You can learn more about this project on GitHub at multicaret/laravel-acquaintances.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.