PHP code example of devkhris / laravel-friendships
1. Go to this page and download the library: Download devkhris/laravel-friendships library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
devkhris / laravel-friendships example snippets
composer
DevKhris\Friendships\FriendshipsServiceProvider::class,
use DevKhris\Friendships\Traits\Friendable;
class User extends Model
{
use Friendable;
...
}
$user->befriend($recipient);
$user->acceptFriendRequest($sender);
$user->denyFriendRequest($sender);
$user->unfriend($friend);
$user->blockFriend($friend);
$user->unblockFriend($friend);
$user->isFriendWith($friend);
$user->hasFriendRequestFrom($sender);
$user->hasSentFriendRequestTo($recipient);
$user->hasBlocked($friend);
$user->isBlockedBy($friend);
$user->getFriendship($friend);
$user->getAllFriendships();
$user->getPendingFriendships();
$user->getPendingFriendshipsDetails($group_name, $paginate);
$user->getAcceptedFriendships();
$user->getDeniedFriendships();
$user->getBlockedFriendships();
$user->getFriendRequests();
$user->getFriendsCount();
$user->getPendingsCount();
$user->getMutualFriendsCount($otherUser);
$user->getFriends();
$user->getFriends($perPage = 20);
$user->getFriendsOfFriends($perPage = 20);
$user->getFriends($perPage = 20, $group_name);
$user->getMutualFriends($otherUser, $perPage = 20);
// config/friendships.php
...
'groups' => [
'acquaintances' => 0,
'close_friends' => 1,
'family' => 2
]
$user->groupFriend($friend, $group_name);
$user->ungroupFriend($friend, 'family');
$user->ungroupFriend($friend);
$user->getFriendsCount($group_name);
$user->getAllFriendships($group_name);
$user->getAcceptedFriendships($group_name);
$user->getPendingFriendships($group_name);
$user->getPendingFriendshipsDetails($group_name, $paginate);
...
php artisan vendor:publish --provider="DevKhris\Friendships\FriendshipsServiceProvider"
config\friendships.php
php artisan migrate