1. Go to this page and download the library: Download x-laravel/followable 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/ */
x-laravel / followable example snippets
use XLaravel\Followable\Concerns\Followable;
use XLaravel\Followable\Concerns\Follower;
use XLaravel\Followable\Contracts\CanFollow;
use XLaravel\Followable\Contracts\HasFollowers;
use XLaravel\Followable\Contracts\RequiresFollowApproval;
class User extends Authenticatable implements CanFollow, HasFollowers, RequiresFollowApproval
{
use Follower;
use Followable;
public function
$user->follow($venue); // returns the Follow, the existing one when already followed
$user->unfollow($venue); // removes a follow or withdraws a pending request
$user->isFollowing($venue); // accepted follows only
$user->hasRequestedToFollow($account);
$account->followRequests()->paginate(); // followers waiting for approval
$account->hasFollowRequestFrom($user);
$account->acceptFollowRequest($user); // true when a pending request was accepted
$account->rejectFollowRequest($user); // true when a pending request was rejected
$account->removeFollower($user); // removes an accepted follower
$venue->followers()->paginate(20); // accepted followers of the default follower model
$venue->followers(Page::class)->get(); // followers of another model
$venue->isFollowedBy($user); // false for null, so a guest can be passed
$user->followings(Venue::class)->get(); // followed venues
$user->sentFollows; // every follow and request the user sent
$venue->receivedFollows; // every follow and request the venue received
Venue::query()
->withCount('followers')
->withFollowedBy($request->user()) // adds is_followed and is_follow_requested
->paginate();
$user->isMutuallyFollowing($other); // both follows accepted
$user->mutualFollowers()->paginate(); // followers the user follows back
User::query()
->withFollowsBack($request->user()) // adds follows_back: the row follows the given model
->paginate();