2017 © Pedro Peláez
 

library laravel-friendships

This package gives Eloquent models the ability to manage their friendships. Fork from https://github.com/hootlex/laravel-friendships

image

asyrafhussin/laravel-friendships

This package gives Eloquent models the ability to manage their friendships. Fork from https://github.com/hootlex/laravel-friendships

  • Saturday, February 11, 2017
  • by AsyrafHussin
  • Repository
  • 0 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 71 Forks
  • 0 Open issues
  • 24 Versions
  • 0 % Grown

The README.md

Laravel 5 Friendships

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

Models can:

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

Installation

First, install the package through Composer., (*2)

composer require asyrafhussin/laravel-friendships

Then include the service provider inside config/app.php., (*3)

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

Publish config and migrations, (*4)

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

Configure the published config in, (*5)

config\friendships.php

Finally, migrate the database, (*6)

php artisan migrate

Setup a Model

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

How to use

Check the Test file to see the package in action, (*7)

Send a Friend Request

$user->befriend($recipient);

Accept a Friend Request

$user->acceptFriendRequest($sender);

Deny a Friend Request

$user->denyFriendRequest($sender);

Remove Friend

$user->unfriend($friend);

Block a Model

$user->blockFriend($friend);

Unblock a Model

$user->unblockFriend($friend);

Check if Model is Friend with another Model

$user->isFriendWith($friend);

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

$user->hasSentFriendRequestTo($recipient);

Check if Model has blocked another Model

$user->hasBlocked($friend);

Check if Model is blocked by another Model

$user->isBlockedBy($friend);

Get a single friendship

$user->getFriendship($friend);

Get a list of all Friendships

$user->getAllFriendships();

Get a list of pending Friendships

$user->getPendingFriendships();

Get a list of accepted Friendships

$user->getAcceptedFriendships();

Get a list of denied Friendships

$user->getDeniedFriendships();

Get a list of blocked Friendships

$user->getBlockedFriendships();

Get a list of pending Friend Requests

$user->getFriendRequests();

Get the number of Friends

$user->getFriendsCount();

Get the number of mutual Friends with another user

$user->getMutualFriendsCount($otherUser);

Friends

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

Get Friends

$user->getFriends();

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., (*9)

// 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., (*10)

Group a Friend

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

Remove a Friend from family group

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

Remove a Friend from all groups

$user->ungroupFriend($friend);

Get the number of Friends in specific group

$user->getFriendsCount($group_name);

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

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

Events

This is the list of the events fired by default for each action, (*11)

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

Contributing

See the CONTRIBUTING guide., (*12)

The Versions

11/02 2017

dev-master

9999999-dev

This package gives Eloquent models the ability to manage their friendships. Fork from https://github.com/hootlex/laravel-friendships

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex
by Asyraf Hussin

laravel eloquent friends friendships friend-system

11/02 2017

v1.0.23

1.0.23.0

This package gives Eloquent models the ability to manage their friendships. Fork from https://github.com/hootlex/laravel-friendships

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex
by Asyraf Hussin

laravel eloquent friends friendships friend-system

11/02 2017

dev-custom

dev-custom

This package gives Eloquent models the ability to manage their friendships. Fork from https://github.com/hootlex/laravel-friendships

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex
by Asyraf Hussin

laravel eloquent friends friendships friend-system

11/02 2017

v1.0.22

1.0.22.0

This package gives Eloquent models the ability to manage their friendships. Fork from https://github.com/hootlex/laravel-friendships

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex
by Asyraf Hussin

laravel eloquent friends friendships friend-system

30/08 2016

v1.0.21

1.0.21.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

22/08 2016

v1.0.20

1.0.20.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

18/08 2016

v1.0.19

1.0.19.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

29/06 2016

v1.0.18

1.0.18.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

02/06 2016

v1.0.17

1.0.17.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

23/05 2016

v1.0.16

1.0.16.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

02/05 2016

v1.0.15

1.0.15.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

31/03 2016

v1.0.14

1.0.14.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

14/03 2016

v1.0.13

1.0.13.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

06/03 2016

v1.0.12

1.0.12.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

05/03 2016

v1.0.11

1.0.11.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

05/03 2016

v1.0.10

1.0.10.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

23/02 2016

v1.0.9

1.0.9.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

16/01 2016

v1.0.8

1.0.8.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

15/01 2016

v1.0.7

1.0.7.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

15/01 2016

v1.0.6

1.0.6.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

26/11 2015

v1.0.5

1.0.5.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendships friend-system eloqent

23/11 2015

v1.0.4

1.0.4.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

laravel friends friendship friendships eloqent

21/11 2015

v1.0.3

1.0.3.0

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Avatar Hootlex

21/11 2015

v1.0.1

1.0.1.0

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

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Hootlex