Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


This package gives Eloquent models the ability to manage their friendships.

Subscribe to updates I use laravel-friendships

Statistics on laravel-friendships

Number of watchers on Github 623
Number of open issues 38
Average time to close an issue 15 days
Main language PHP
Average time to merge a PR 2 days
Open pull requests 18+
Closed pull requests 12+
Last commit over 2 years ago
Repo Created about 5 years ago
Repo Last Updated 5 months ago
Size 120 KB
Organization / Authorhootlex
Latest Releasev1.0.24
Page Updated
Do you use laravel-friendships? Leave a review!
View open issues (38)
View laravel-friendships activity
View on github
Book a Mock Interview With Me (Silicon Valley Engineering Leader, 100s of interviews conducted)
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating laravel-friendships for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Laravel 5 Friendships

Build Status Code Climate Test Coverage Total Downloads Version Software License Join the chat at https://gitter.im/laravel-friendships/Lobby

This package gives Eloquent models the ability to manage their friendships. You can easily design a Facebook like Friend System.

Models can:

  • Send Friend Requests
  • Accept Friend Requests
  • Deny Friend Requests
  • Block Another Model
  • Group Friends


First, install the package through Composer.

composer require hootlex/laravel-friendships

If you are using Laravel < 5.5, you need to add Hootlex\Friendships\FriendshipsServiceProvider to your config/app.php providers array:


Publish config and migrations

php artisan vendor:publish --provider="Hootlex\Friendships\FriendshipsServiceProvider"

Configure the published config in


Finally, migrate the database

php artisan migrate

Setup a Model

use Hootlex\Friendships\Traits\Friendable;
class User extends Model
    use Friendable;

How to use

Check the Test file to see the package in action

Send a Friend Request


Accept a Friend Request


Deny a Friend Request


Remove Friend


Block a Model


Unblock a Model


Check if Model is Friend with another Model


Check if Model has a pending friend request from another Model


Check if Model has already sent a friend request to another Model


Check if Model has blocked another Model


Check if Model is blocked by another Model


Get a single friendship


Get a list of all Friendships


Get a list of pending Friendships


Get a list of accepted Friendships


Get a list of denied Friendships


Get a list of blocked Friendships


Get a list of pending Friend Requests


Get the number of Friends


Get the number of Pendings


Get the number of mutual Friends with another user



To get a collection of friend models (ex. User) use the following methods:

Get Friends


Get Friends Paginated

$user->getFriends($perPage = 20);

Get Friends of Friends

$user->getFriendsOfFriends($perPage = 20);

Collection of Friends in specific group paginated:

$user->getFriends($perPage = 20, $group_name);

Get mutual Friends with another user

$user->getMutualFriends($otherUser, $perPage = 20);

Friend groups

The friend groups are defined in the config/friendships.php file. The package comes with a few default groups. To modify them, or add your own, you need to specify a slug and a key.

// config/friendships.php
'groups' => [
    'acquaintances' => 0,
    'close_friends' => 1,
    'family' => 2

Since you've configured friend groups, you can group/ungroup friends using the following methods.

Group a Friend

$user->groupFriend($friend, $group_name);

Remove a Friend from family group

$user->ungroupFriend($friend, 'family');

Remove a Friend from all groups


Get the number of Friends in specific group


To filter friendships by group you can pass a group slug.



This is the list of the events fired by default for each action

Event name Fired
friendships.sent When a friend request is sent
friendships.accepted When a friend request is accepted
friendships.denied When a friend request is denied
friendships.blocked When a friend is blocked
friendships.unblocked When a friend is unblocked
friendships.cancelled When a friendship is cancelled


See the CONTRIBUTING guide.

laravel-friendships open issues Ask a question     (View All Issues)
  • about 4 years getFriendRequests with recipient object
  • about 4 years Groups in config
  • about 4 years getPendingFriends
laravel-friendships open pull requests (View All Pulls)
  • Added three new methods for limit and pagination when getting Friends(accepted)
  • [WIP] Add access to query builder with friends() and friendships() method in friendable trait
  • Add method to find mutual friends
  • Add user's personal groups (acquaintances, family, etс.) support
  • Improve the travis build
  • [WIP] Add deprecate notes
  • Upd Groups config, add getGroupsFor()
  • Physio patch 1
  • Update readme.md
  • Ability to specify fields && code alignment
  • Incoming and outgoing friend requests
  • Allow models to get friendships requested by others
  • Add support for Laravel 6
  • Support for Laravel 5.8
  • Support for laravel 5.8
  • Updated the package to support laravel 5.8
  • Adding Query to get Pending Friend Requests
  • Fix bug with whereGroup scope
laravel-friendships list of languages used
laravel-friendships latest release notes
v1.0.24 v1.0.24

Emit events after database changes

v1.0.23 v1.0.23

Use complete namespace for Event

v1.0.22 v1.0.22
  • Support for Laravel 5.4
  • Improve PHPdoc / IDE autocomplete
Other projects in PHP
Powered by Autocode - Instant Webhooks, Scripts and APIs
Autocode logo wordmark