Indexed by TopGit from live GitHub metadata: overtrue/laravel-follow has 1.2k stars, written primarily in PHP. :heart: This package helps you to add user based follow system to your model.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
foreach($user->followings()->with('followable')->get() as $following)
{
$following->created_at; // followed at
$following->followable->nickname; // the user attributes
}
foreach($user->followers()->with('followers')->get() as $follower)
{
$follower->created_at; // followed at
$follower->follower->nickname; // the user attributes
}
Follow Requests
If you would like to have some follow requests to need to be accepted by the user being followed, simply override the needsToApproveFollowRequests() method in the model that uses the Followable trait with your custom logic:
public function needsToApproveFollowRequests()
{
// Your custom logic here
return (bool) $this->private;
}
Aggregations
// followings count
$user->followings()->count();
$user->approvedFollowings()->count();
$user->notApprovedFollowings()->count();
// with query where
$user->followings()->where('gender', 'female')->count();
// followers count
$user->followers()->count();
$user->approvedFollowers()->count();
$user->notApprovedFollowers()->count();
List with *_count attribute:
$users = User::withCount(['followings', 'followables'])->get();
// or
$users = User::withCount(['approvedFollowings', 'approvedFollowers'])->get();
foreach($users as $user) {
// $user->followings_count;
// $user->followers_count;
// or
// $user->approved_followings_count;
// $user->approved_followers_count;
}
Attach user follow status to followable collection
You can use Follower::attachFollowStatus(Collection $followables) to attach the user follow status, it will set has_followed attribute to each model of $followables:
To avoid the N+1 issue, you can use eager loading to reduce this operation to just 2 queries. When querying, you may specify which relationships should be eager loaded using the with method:
$users = User::with('followings')->get();
foreach($users as $user) {
$user->isFollowing(2);
}
$users = User::with('followables')->get();
foreach($users as $user) {
$user->isFollowedBy(2);
}
Events
Event
Description
Overtrue\LaravelFollow\Events\Followed
Triggered when the relationship is created.
Overtrue\LaravelFollow\Events\Unfollowed
Triggered when the relationship is deleted.
:heart: Sponsor me
如果你喜欢我的项目并想支持它,点击这里 :heart:
Project supported by JetBrains
Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.
Contributing
You can contribute in one of three ways:
File bug reports using the issue tracker.
Answer questions or fix bugs on the issue tracker.
Contribute new features or update the wiki.
The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.
How active is development on overtrue/laravel-follow?
The most recent commit recorded on overtrue/laravel-follow was 6 months ago, based on the GitHub push timestamp. The repository has 134 forks — one of the better signals of community interest.
How does overtrue/laravel-follow compare to other Backend projects?
overtrue/laravel-follow is tracked by TopGit in the Backend category, with 1.2k GitHub stars and written in PHP. Browse the Backend topic page on TopGit to compare it against similar projects by stars and activity.
How many stars does overtrue/laravel-follow have?
overtrue/laravel-follow has 1.2k GitHub stars — refresh the page for the live number, or check github.com/overtrue/laravel-follow. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is overtrue/laravel-follow open source?
Yes — overtrue/laravel-follow ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/overtrue/laravel-follow.
What is overtrue/laravel-follow?
overtrue/laravel-follow (overtrue/laravel-follow) is a PHP project on GitHub. From the project's own README: :heart: This package helps you to add user based follow system to your model.
Where do I read more about overtrue/laravel-follow?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/overtrue/laravel-follow is the definitive source.
Read full README in the tab above.
Curious whether laravel-follow is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about laravel-follow.