PHPackages                             obb12/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. obb12/laravel-friendships

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

obb12/laravel-friendships
=========================

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

032PHP

Since May 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/obb12/laravel-friendshipz)[ Packagist](https://packagist.org/packages/obb12/laravel-friendships)[ RSS](/packages/obb12-laravel-friendships/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel 5 Friendships [![Build Status](https://camo.githubusercontent.com/4c74f1f00a90c872c339747cac329b40a39bafeab5271e176de2cfb5864b9cf4/68747470733a2f2f7472617669732d63692e6f72672f686f6f746c65782f6c61726176656c2d667269656e6473686970732e7376673f6272616e63683d76312e302e3137)](https://travis-ci.org/hootlex/laravel-friendships) [![Total Downloads](https://camo.githubusercontent.com/687e5957e92c2a7bac226e2b3a689d0a33c8e2bf4aecef104f492859e2929058/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686f6f746c65782f6c61726176656c2d667269656e6473686970732e7376673f7374796c653d666c6174)](https://packagist.org/packages/hootlex/laravel-friendships) [![Version](https://camo.githubusercontent.com/4abef014a3ac76d1bf65b3676fc6dca7cb10b87a9b22af9007cf10e40883a437/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f686f6f746c65782f6c61726176656c2d667269656e6473686970732e7376673f7374796c653d666c6174)](https://packagist.org/packages/hootlex/laravel-friendships) [![Software License](https://camo.githubusercontent.com/f251623e510f5909f16ae3f4e6e548dac11340b9fde1a99be26b015b39272c00/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c6174)](LICENSE)
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#laravel-5-friendships-----)

This package gives Eloqent 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

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

[](#installation)

First, install the package through Composer.

```
composer require hootlex/laravel-friendships
```

Then include the service provider inside `config/app.php`.

```
'providers' => [
    ...
    Hootlex\Friendships\FriendshipsServiceProvider::class,
    ...
];
```

Lastly you need to publish the migration and migrate the database

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

```

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

[](#setup-a-model)

```
use Hootlex\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/hootlex/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($recipient);
```

#### Deny a Friend Request

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

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

#### Remove Friend

[](#remove-friend)

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

#### Block a Model

[](#block-a-model)

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

#### Unblock a Model

[](#unblock-a-model)

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

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

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

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

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

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

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

#### Check if Model has blocked another Model

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

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

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

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

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

#### Get a single friendship

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

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

#### 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();
```

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

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

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/25f431666857bf5427c4296b63715d3578f07a85ac6decec06f7600ebc286c40?d=identicon)[obb12](/maintainers/obb12)

---

Top Contributors

[![obb12](https://avatars.githubusercontent.com/u/8593284?v=4)](https://github.com/obb12 "obb12 (2 commits)")

### Embed Badge

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

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

PHPackages © 2026

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