New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

merodiro/friendships

This package gives users the ability to manage their friendships.
9,719 45

Larablocks Analysis

merodiro/friendships works with Laravel 5 (latest release v1.2.4, May 16, 2018), which reached end of life: no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 5, past end of life
  • No release in the last 12 months (last: May 16, 2018)
  • 3 downloads a month (needs 10,000)
  • 45 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: May 16, 2018.
  • No releases in the last 12 months.
  • First released: May 8, 2017.
  • Monthly downloads: 3, up 50% from six months ago.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.

Install
composer require merodiro/friendships
Latest Version:v1.2.4
PHP:>=7.0.0
Laravel:5
License:MIT
Last Updated:Dec 9, 2020
Links: GitHub  ·  Packagist
Maintainer: merodiro

Laravel 5 Friendships

Latest Version on Packagist Software License Build Status Build status Coverage Status Quality Score Total Downloads

This package gives users the ability to manage their friendships.

Models can:

  • Send Friend Requests
  • Accept Friend Requests
  • Deny Friend Requests
  • Delete Friend

Installation

First, install the package through Composer.

composer require merodiro/friendships

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

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

Finally, migrate the database

php artisan migrate

Setup a Model

use Merodiro\Friendships\Friendable;
class User extends Model
{
    use Friendable;
    ...
}

How to use

Check the Test file to see the package in action

Send a Friend Request
$user->addFriend($recipient);
Accept a Friend Request
$user->acceptFriend($sender);
Deny a Friend Request
$user->deleteFriend($sender);
Remove Friend
$user->deleteFriend($friend);
Mutual Friends
$user->mutualFriends($anotherUser);
check the current relationship between two users
$user->checkFriendship($anotherUser);

it returns

  • same_user => if the $user is checking his own account
  • friends => if they are friends
  • waiting => if $user sent a request waiting for approval from $anotherUser
  • pending => if $anotherUser user sent a request waiting for approval from $user
  • not_friends => if they are not friends
Check if two users are friends
$user->isFriendsWith($anotherUser);

it returns true if they are friends and false if they aren't

Friends

To get a collection of users use the following methods:

Get Friends
$user->friends();
Get a list of users that $user has received friend requests from
$user->friendRequestsReceived();
Get a list of users that $user has sent friend requests to
$user->friendRequestsSent();

Events

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

Event name Fired
friendrequest.sent When a friend request is sent
friendrequest.accepted When a friend request is accepted
friendship.deleted When a friend request is denied
friendship.deleted When a friendship is deleted

for more about how to use the events Check this example

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security-related issues, please email merodiro@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

multicaret/laravel-acquaintances

This light package, with no dependencies, gives Eloquent models the ability to m...

343,455 850
sofa/hookable

Laravel Eloquent hooks system.

2,059,111 64
volosyuk/simple-eloquent

Adaptation of eloquent for retrieving its attributes

119,868 55
gzero/eloquent-tree

Eloquent Tree is a tree model for Laravel Eloquent ORM.

60,021 131
martinbean/laravel-sluggable-trait

A trait you can apply to Eloquent models to have slugs automatically generated o...

49,246 24

Version History

Version Released PHP Laravel License
v1.2.4 >=7.0.0 ^5.6 MIT
v1.2.3 >=7.0.0 ^5.6 MIT
v1.2.2 >=7.0.0 ^5.6 MIT
v1.2.1 >=7.0.0 ^5.6 MIT
v1.2.0 >=7.0.0 ^5.6 MIT