PHP code example of timgavin / laravel-follow

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

    

timgavin / laravel-follow example snippets


namespace App\Models;

use TimGavin\LaravelFollow\LaravelFollow;

class User extends Authenticatable
{
    use LaravelFollow;
}

auth()->user()->follow($user);

auth()->user()->unfollow($user);

@if (auth()->user()->isFollowing($user))
    You are following this user.
@endif

@if (auth()->user()->isFollowedBy($user))
    This user is following you.
@endif

auth()->user()->getFollowing();

auth()->user()->getFollowers();

// default limit is 5
auth()->user()->getLatestFollowers($limit);

auth()->user()->getFollowingIds();

auth()->user()->getFollowersIds();

auth()->user()->getFollowingAndFollowersIds()

// 1 day
auth()->user()->cacheFollowing();

// 1 hour
auth()->user()->cacheFollowing(3600);

// 1 month
auth()->user()->cacheFollowing(Carbon::addMonth());

auth()->user()->getFollowingCache();

auth()->user()->cacheFollowers();

auth()->user()->getFollowersCache();

auth()->user()->clearFollowingCache();

auth()->user()->clearFollowersCache();

php artisan migrate