This package gives Eloqent models the ability to manage their friendships.
obb12/laravel-friendships is a Laravel package for this package gives eloqent models the ability to manage their friendships..
It currently has 0 GitHub stars and 32 downloads on Packagist.
Install it with composer require obb12/laravel-friendships.
Discover more Laravel packages by obb12
or browse all Laravel packages to compare alternatives.
Last updated
This package gives Eloqent models the ability to manage their friendships. You can easily design a Facebook like Friend System.
##Models can:
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
use Hootlex\Friendships\Traits\Friendable;
class User extends Model
{
use Friendable;
...
}
Check the Test file to see the package in action
$user->befriend($recipient);
$user->acceptFriendRequest($recipient);
$user->denyFriendRequest($recipient);
$user->unfriend($recipient);
$user->blockFriend($recipient);
$user->unblockFriend($recipient);
$user->isFriendWith($recipient);
$user->hasFriendRequestFrom($recipient);
$user->hasBlocked($recipient);
$user->isBlockedBy($recipient);
$user->getFriendship($recipient);
$user->getAllFriendships();
$user->getPendingFriendships();
$user->getAcceptedFriendships();
$user->getDeniedFriendships();
$user->getBlockedFriendships();
$user->getFriendRequests();
$user->getFriendsCount();
$user->getFriends();
$user->getFriends($perPage = 20);
$user->getFriendsOfFriends($perPage = 20);