Require this package, with Composer, in the root directory of your project.
$ composer require faustbrian/laravel-friendable
And then include the service provider within app/config/app.php
.
BrianFaust\Friendable\FriendableServiceProvider::class
To get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="BrianFaust\Friendable\FriendableServiceProvider" && php artisan migrate
<?php
namespace App;
use BrianFaust\Friendable\HasFriendsTrait;
use BrianFaust\Friendable\Interfaces\HasFriends;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements HasFriends
{
use HasFriendsTrait;
}
$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();
If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at hello@brianfaust.de. All security vulnerabilities will be promptly addressed.