PHP code example of ashmawi / laravel-follow

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

    

ashmawi / laravel-follow example snippets


use Ashmawi\LaravelFollow\Traits\Followable;

class User extends Authenticatable
{
    use Followable;
}

$user1->follow($user2);
$user1->unfollow($user2);

$user1->isFollowing($user2)

$user->followings

$user->followers

// followings count
$user->followings()->count();

// with query where
$user->followings()->where('x', 'x')->count();

// followers count
$user->followers()->count();

$ php artisan migrate