1. Go to this page and download the library: Download laravel-interaction/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/ */
laravel-interaction / follow example snippets
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Follow\Concerns\Follower;
class User extends Model
{
use Follower;
}
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Follow\Concerns\Followable;
class Channel extends Model
{
use Followable;
}
use LaravelInteraction\Follow\Tests\Models\Channel;
/** @var \LaravelInteraction\Follow\Tests\Models\User $user */
/** @var \LaravelInteraction\Follow\Tests\Models\Channel $channel */
// Follow to Followable
$user->follow($channel);
$user->unfollow($channel);
$user->toggleFollow($channel);
// Compare Followable
$user->hasFollowed($channel);
$user->hasNotFollowed($channel);
// Get followed info
$user->followerFollowings()->count();
// with type
$user->followerFollowings()->withType(Channel::class)->count();
// get followed channels
Channel::query()->whereFollowedBy($user)->get();
// get followed channels doesnt followed
Channel::query()->whereNotFollowedBy($user)->get();