Use At Your Own Risk - Not Maintained!
First, pull in the package through Composer.
"require": {
"draperstudio/laravel-friendable": "~1.0"
}
And then include the service provider within app/config/app.php
.
'providers' => [
'DraperStudio\Friendable\FriendableServiceProvider'
];
At last you need to publish and run the migration.
php artisan vendor:publish && php artisan migrate
<?php
namespace App;
use DraperStudio\Friendable\Traits\Friendable;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use Friendable;
}
$user->befriend($userToBeFriendsWith);
$user->unfriend($userToBeFriendsWith);
$user->denyFriendRequest($userToBeFriendsWith);
$user->acceptFriendRequest($userToBeFriendsWith);
$user->blockFriendRequest($userToBeFriendsWith);
$user->unblockFriendRequest($userToBeFriendsWith);
$user->hasBlocked($userToBeFriendsWith);
$user->isBlockedBy($userToBeFriendsWith);
$user->isFriendsWith($userToBeFriendsWith);
$user->getFriendship($userToBeFriendsWith);
$user->getAllFriendships();
$user->getPendingFriendships();
$user->getAcceptedFriendships();
$user->getDeniedFriendships();
$user->getBlockedFriendships();
$user->getFriendRequests();