PHP code example of gregoryduckworth / friendable

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

    

gregoryduckworth / friendable example snippets


'providers' => [
    ...
    GregoryDuckworth\Friendable\FriendableServiceProvider::class,
    ...
];

Add the Trait to the User Model

use GregoryDuckworth\Friendable\Traits\Friendable;

class User extends Model
{
    use Friendable;
    ...
}

    $user->confirmedFriends();

    $user->pendingFriends();

    $user->awaitingApproval();

    $user->requestFriendship(Model $friend);

    $user->confirmFriendship(Model $friend);

    $user->removeFriendship(Model $friend);

php artisan vendor:publish && php artisan migrate