2017 © Pedro Peláez
 

library laravel-friendships

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

image

obb12/laravel-friendships

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

  • Friday, May 26, 2017
  • by obb12
  • Repository
  • 1 Watchers
  • 1 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel 5 Friendships Build Status Total Downloads Version Software License

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

Installation

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

composer require hootlex/laravel-friendships

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

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

Lastly you need to publish the migration and migrate the database, (*4)

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

Setup a Model

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

How to use

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

Send a Friend Request

$user->befriend($recipient);

Accept a Friend Request

$user->acceptFriendRequest($recipient);

Deny a Friend Request

$user->denyFriendRequest($recipient);

Remove Friend

$user->unfriend($recipient);

Block a Model

$user->blockFriend($recipient);

Unblock a Model

$user->unblockFriend($recipient);

Check if Model is Friend with another Model

$user->isFriendWith($recipient);

Check if Model has a pending friend request from another Model

$user->hasFriendRequestFrom($recipient);

Check if Model has blocked another Model

$user->hasBlocked($recipient);

Check if Model is blocked by another Model

$user->isBlockedBy($recipient);

Get a single friendship

$user->getFriendship($recipient);

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

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

Get Friends

$user->getFriends();

Get Friends Paginated

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

Get Friends of Friends

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

The Versions

26/05 2017

dev-master

9999999-dev

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

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Interfriendz

laravel friends friendships friend-system eloqent