PHPackages                             giliomeejg/laravel-friendships - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. giliomeejg/laravel-friendships

ActiveLibrary[Database &amp; ORM](/categories/database)

giliomeejg/laravel-friendships
==============================

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

v1.0.25(6y ago)12.3kMITPHPPHP &gt;=5.4.0

Since Nov 21Pushed 6y agoCompare

[ Source](https://github.com/giliomeejg/laravel-friendships)[ Packagist](https://packagist.org/packages/giliomeejg/laravel-friendships)[ RSS](/packages/giliomeejg-laravel-friendships/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (6)Versions (25)Used By (0)

Laravel 5 Friendships
=====================

[](#laravel-5-friendships)

This is a clone of [hootlex/laravel-friendships](https://github.com/hootlex/laravel-friendships) that includes support for Laravel 5.8 as the original package does not seem to be maintained anymore.

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

Models can:
-----------

[](#models-can)

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

Installation
------------

[](#installation)

First, install the package through Composer.

```
composer require giliomeejg/laravel-friendships
```

If you are using Laravel &lt; 5.5, you need to add giliomeejg\\Friendships\\FriendshipsServiceProvider to your `config/app.php` providers array:

```
giliomeejg\Friendships\FriendshipsServiceProvider::class,
```

Publish config and migrations

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

```

Configure the published config in

```
config\friendships.php

```

Finally, migrate the database

```
php artisan migrate

```

Setup a Model
-------------

[](#setup-a-model)

```
use giliomeejg\Friendships\Traits\Friendable;
class User extends Model
{
    use Friendable;
    ...
}
```

How to use
----------

[](#how-to-use)

[Check the Test file to see the package in action](https://github.com/giliomeejg/laravel-friendships/blob/master/tests/FriendshipsTest.php)

#### Send a Friend Request

[](#send-a-friend-request)

```
$user->befriend($recipient);
```

#### Accept a Friend Request

[](#accept-a-friend-request)

```
$user->acceptFriendRequest($sender);
```

#### Deny a Friend Request

[](#deny-a-friend-request)

```
$user->denyFriendRequest($sender);
```

#### Remove Friend

[](#remove-friend)

```
$user->unfriend($friend);
```

#### Block a Model

[](#block-a-model)

```
$user->blockFriend($friend);
```

#### Unblock a Model

[](#unblock-a-model)

```
$user->unblockFriend($friend);
```

#### Check if Model is Friend with another Model

[](#check-if-model-is-friend-with-another-model)

```
$user->isFriendWith($friend);
```

#### Check if Model has a pending friend request from another Model

[](#check-if-model-has-a-pending-friend-request-from-another-model)

```
$user->hasFriendRequestFrom($sender);
```

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

[](#check-if-model-has-already-sent-a-friend-request-to-another-model)

```
$user->hasSentFriendRequestTo($recipient);
```

#### Check if Model has blocked another Model

[](#check-if-model-has-blocked-another-model)

```
$user->hasBlocked($friend);
```

#### Check if Model is blocked by another Model

[](#check-if-model-is-blocked-by-another-model)

```
$user->isBlockedBy($friend);
```

#### Get a single friendship

[](#get-a-single-friendship)

```
$user->getFriendship($friend);
```

#### Get a list of all Friendships

[](#get-a-list-of-all-friendships)

```
$user->getAllFriendships();
```

#### Get a list of pending Friendships

[](#get-a-list-of-pending-friendships)

```
$user->getPendingFriendships();
```

#### Get a list of accepted Friendships

[](#get-a-list-of-accepted-friendships)

```
$user->getAcceptedFriendships();
```

#### Get a list of denied Friendships

[](#get-a-list-of-denied-friendships)

```
$user->getDeniedFriendships();
```

#### Get a list of blocked Friendships

[](#get-a-list-of-blocked-friendships)

```
$user->getBlockedFriendships();
```

#### Get a list of pending Friend Requests

[](#get-a-list-of-pending-friend-requests)

```
$user->getFriendRequests();
```

#### Get the number of Friends

[](#get-the-number-of-friends)

```
$user->getFriendsCount();
```

#### Get the number of Pendings

[](#get-the-number-of-pendings)

```
$user->getPendingsCount();
```

#### Get the number of mutual Friends with another user

[](#get-the-number-of-mutual-friends-with-another-user)

```
$user->getMutualFriendsCount($otherUser);
```

Friends
-------

[](#friends)

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

#### Get Friends

[](#get-friends)

```
$user->getFriends();
```

#### Get Friends Paginated

[](#get-friends-paginated)

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

#### Get Friends of Friends

[](#get-friends-of-friends)

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

#### Collection of Friends in specific group paginated:

[](#collection-of-friends-in-specific-group-paginated)

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

#### Get mutual Friends with another user

[](#get-mutual-friends-with-another-user)

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

Friend groups
-------------

[](#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

[](#group-a-friend)

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

#### Remove a Friend from family group

[](#remove-a-friend-from-family-group)

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

#### Remove a Friend from all groups

[](#remove-a-friend-from-all-groups)

```
$user->ungroupFriend($friend);
```

#### Get the number of Friends in specific group

[](#get-the-number-of-friends-in-specific-group)

```
$user->getFriendsCount($group_name);
```

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

[](#to-filter-friendships-by-group-you-can-pass-a-group-slug)

```
$user->getAllFriendships($group_name);
$user->getAcceptedFriendships($group_name);
$user->getPendingFriendships($group_name);
...
```

Events
------

[](#events)

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

Event nameFiredfriendships.sentWhen a friend request is sentfriendships.acceptedWhen a friend request is acceptedfriendships.deniedWhen a friend request is deniedfriendships.blockedWhen a friend is blockedfriendships.unblockedWhen a friend is unblockedfriendships.cancelledWhen a friendship is cancelledContributing
------------

[](#contributing)

See the [CONTRIBUTING](CONTRIBUTING.md) guide.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 65.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~280 days

Total

24

Last Release

2420d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/19786448?v=4)[Gerrit Giliomee](/maintainers/giliomeejg)[@giliomeejg](https://github.com/giliomeejg)

---

Top Contributors

[![hootlex](https://avatars.githubusercontent.com/u/6147968?v=4)](https://github.com/hootlex "hootlex (152 commits)")[![stephane-monnot](https://avatars.githubusercontent.com/u/6066368?v=4)](https://github.com/stephane-monnot "stephane-monnot (35 commits)")[![nikolaynesov](https://avatars.githubusercontent.com/u/17743574?v=4)](https://github.com/nikolaynesov "nikolaynesov (23 commits)")[![giliomeejg](https://avatars.githubusercontent.com/u/19786448?v=4)](https://github.com/giliomeejg "giliomeejg (6 commits)")[![davidavz](https://avatars.githubusercontent.com/u/6774576?v=4)](https://github.com/davidavz "davidavz (5 commits)")[![irazasyed](https://avatars.githubusercontent.com/u/1915268?v=4)](https://github.com/irazasyed "irazasyed (1 commits)")[![kainxspirits](https://avatars.githubusercontent.com/u/5594710?v=4)](https://github.com/kainxspirits "kainxspirits (1 commits)")[![nahid](https://avatars.githubusercontent.com/u/3167309?v=4)](https://github.com/nahid "nahid (1 commits)")[![nilportugues](https://avatars.githubusercontent.com/u/550948?v=4)](https://github.com/nilportugues "nilportugues (1 commits)")[![physio](https://avatars.githubusercontent.com/u/729118?v=4)](https://github.com/physio "physio (1 commits)")[![arubacao](https://avatars.githubusercontent.com/u/7462542?v=4)](https://github.com/arubacao "arubacao (1 commits)")[![vedmant](https://avatars.githubusercontent.com/u/5052406?v=4)](https://github.com/vedmant "vedmant (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")[![clarkewing](https://avatars.githubusercontent.com/u/7689302?v=4)](https://github.com/clarkewing "clarkewing (1 commits)")[![DCzajkowski](https://avatars.githubusercontent.com/u/4501047?v=4)](https://github.com/DCzajkowski "DCzajkowski (1 commits)")[![gitter-badger](https://avatars.githubusercontent.com/u/8518239?v=4)](https://github.com/gitter-badger "gitter-badger (1 commits)")

---

Tags

laraveleloquentfriendsfriendshipsfriend-system

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/giliomeejg-laravel-friendships/health.svg)

```
[![Health](https://phpackages.com/badges/giliomeejg-laravel-friendships/health.svg)](https://phpackages.com/packages/giliomeejg-laravel-friendships)
```

###  Alternatives

[multicaret/laravel-acquaintances

This light package, with no dependencies, gives Eloquent models the ability to manage friendships (with groups), verifications, and interactions such as: Likes, favorites, votes, subscribe, follow, ..etc. And it includes advanced rating system.

851266.9k2](/packages/multicaret-laravel-acquaintances)[hootlex/laravel-friendships

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

705114.6k](/packages/hootlex-laravel-friendships)[merodiro/friendships

This package gives users the ability to manage their friendships.

459.7k](/packages/merodiro-friendships)[rennokki/befriended

Eloquent Befriended brings social media-like features like following, blocking and filtering content based on following or blocked models.

76292.2k1](/packages/rennokki-befriended)[demency/laravel-friendships

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

201.0k](/packages/demency-laravel-friendships)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

394388.0k5](/packages/rtconner-laravel-likeable)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
