PHP code example of ghanem / friendship

1. Go to this page and download the library: Download ghanem/friendship 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/ */

    

ghanem / friendship example snippets


'providers' => [
    Ghanem\Friendship\FriendshipServiceProvider::class
];



namespace App;

use Ghanem\Friendship\Contracts\Friendable;
use Ghanem\Friendship\Traits\Friendable as FriendableTrait;
use Illuminate\Database\Eloquent\Model;

class User extends Model implements Friendable
{
    use FriendableTrait;
}

$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();

php artisan vendor:publish --provider="Ghanem\Friendship\FriendshipServiceProvider" 

php artisan migrate