| Package Data | |
|---|---|
| Maintainer Username: | obb12 |
| Maintainer Contact: | omar.bb@hotmail.fi (Interfriendz) |
| Package Create Date: | 2016-07-11 |
| Package Last Update: | 2017-05-26 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-31 03:04:45 |
| Package Statistics | |
|---|---|
| Total Downloads: | 32 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 0 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
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);