PHPackages                             user-pixel-error/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. user-pixel-error/laravel-friendships

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

user-pixel-error/laravel-friendships
====================================

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

v1.0.2(1mo ago)00MITPHPPHP ^8.2CI passing

Since Jul 4Pushed 1mo agoCompare

[ Source](https://github.com/user-error-pixel/laravel-friendships)[ Packagist](https://packagist.org/packages/user-pixel-error/laravel-friendships)[ RSS](/packages/user-pixel-error-laravel-friendships/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (10)Versions (5)Used By (0)

[![Tests](https://github.com/user-error-pixel/laravel-friendships/actions/workflows/tests.yml/badge.svg)](https://github.com/user-error-pixel/laravel-friendships/actions/workflows/tests.yml)[![Latest Version on Packagist](https://camo.githubusercontent.com/523d563361ecbe71d656c8ca8cfa16d49fa72854f58c4d7569d462f7de630d3b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f757365722d706978656c2d6572726f722f6c61726176656c2d667269656e6473686970732e737667)](https://packagist.org/packages/user-pixel-error/laravel-friendships)[![Total Downloads](https://camo.githubusercontent.com/aeb876c83e38be4d7899126e6623ea8f42ce9f69b4ec6c377647a23da718138f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f757365722d706978656c2d6572726f722f6c61726176656c2d667269656e6473686970732e737667)](https://packagist.org/packages/user-pixel-error/laravel-friendships)[![PHP Version](https://camo.githubusercontent.com/9f8db9a7540b54a3495c95b21e48a553e55b959036b3cb5cd277f40119b43423/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f757365722d706978656c2d6572726f722f6c61726176656c2d667269656e6473686970732e737667)](https://packagist.org/packages/user-pixel-error/laravel-friendships)

PixelError Laravel Friendships
==============================

[](#pixelerror-laravel-friendships)

PixelError Laravel Friendships is a Laravel package that allows Eloquent models to manage social relationships.

It can be used to build features like:

- Friend requests
- Accepted friendships
- Denied friend requests
- Blocking users
- Friend groups such as close friends, family, or acquaintances

This package is useful for social platforms, gaming communities, forums, dashboards, team systems, and applications where users need to connect with each other.

---

Table of Contents
-----------------

[](#table-of-contents)

- [Supported Versions](#supported-versions)
- [Features](#features)
- [Installation](#installation)
- [Publish Configuration](#publish-configuration)
- [Publish Migrations](#publish-migrations)
- [Setup a Model](#setup-a-model)
- [Basic Usage](#basic-usage)
- [Send a Friend Request](#send-a-friend-request)
- [Accept a Friend Request](#accept-a-friend-request)
- [Deny a Friend Request](#deny-a-friend-request)
- [Remove a Friend](#remove-a-friend)
- [Block a Model](#block-a-model)
- [Unblock a Model](#unblock-a-model)
- [Checking Friendship Status](#checking-friendship-status)
    - [Check if Two Models Are Friends](#check-if-two-models-are-friends)
    - [Check if a User Has a Pending Friend Request From Another User](#check-if-a-user-has-a-pending-friend-request-from-another-user)
    - [Check if a User Has Sent a Friend Request](#check-if-a-user-has-sent-a-friend-request)
    - [Check if a User Has Blocked Another User](#check-if-a-user-has-blocked-another-user)
    - [Check if a User Is Blocked By Another User](#check-if-a-user-is-blocked-by-another-user)
- [Retrieving Friendships](#retrieving-friendships)
    - [Get a Single Friendship](#get-a-single-friendship)
    - [Get All Friendships](#get-all-friendships)
    - [Get Pending Friendships](#get-pending-friendships)
    - [Get Accepted Friendships](#get-accepted-friendships)
    - [Get Denied Friendships](#get-denied-friendships)
    - [Get Blocked Friendships](#get-blocked-friendships)
    - [Get Friend Requests](#get-friend-requests)
- [Retrieving Friends](#retrieving-friends)
    - [Get Friends Collection](#get-friends-collection)
    - [Get Friends With Pagination](#get-friends-with-pagination)
- [Friend Groups](#friend-groups)
    - [Add a Friend to a Group](#add-a-friend-to-a-group)
    - [Remove a Friend From a Specific Group](#remove-a-friend-from-a-specific-group)
    - [Remove a Friend From All Groups](#remove-a-friend-from-all-groups)
- [Example Controller Usage](#example-controller-usage)
- [Example Routes](#example-routes)
- [Example Blade Usage](#example-blade-usage)
    - [Send Friend Request Button](#send-friend-request-button)
    - [Accept or Deny Friend Request Buttons](#accept-or-deny-friend-request-buttons)
    - [Remove Friend Button](#remove-friend-button)
    - [Block User Button](#block-user-button)
- [Common Friendship Flow](#common-friendship-flow)
- [Notes](#notes)
- [Testing](#testing)
- [License](#license)

---

Supported Versions
------------------

[](#supported-versions)

Package VersionPHPLaravel / IlluminateCurrent`^8.2``^12.0 || ^13.0`> Laravel 12 supports PHP 8.2+. Laravel 13 requires PHP 8.3+. Composer will automatically resolve compatible versions based on your project.

---

Features
--------

[](#features)

Models using this package can:

- Send friend requests
- Accept friend requests
- Deny friend requests
- Remove friends
- Block other models
- Unblock other models
- Check friendship status
- Check pending friend requests
- Retrieve all friendships
- Retrieve pending friendships
- Retrieve accepted friendships
- Retrieve denied friendships
- Retrieve blocked friendships
- Retrieve friend requests
- Retrieve friends as a collection or paginated list
- Assign friends to groups
- Remove friends from groups

---

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

[](#installation)

Install the package using Composer:

```
composer require user-pixel-error/laravel-friendships
```

Laravel should automatically discover the package service provider.

---

Publish Configuration
---------------------

[](#publish-configuration)

Publish the package configuration file:

```
php artisan vendor:publish --provider="PixelError\Friendships\FriendshipsServiceProvider" --tag="friendships-config"
```

This will create the config file at:

```
config/friendships.php

```

The config file controls the table names and default friendship groups.

Example:

```
