PHPackages                             raomingchao/oc-laravel-follow - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. raomingchao/oc-laravel-follow

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

raomingchao/oc-laravel-follow
=============================

Laravel 5 User Based System

1.1.4(8y ago)012MITPHPPHP &gt;=5.5.9

Since Nov 11Pushed 5y ago1 watchersCompare

[ Source](https://github.com/raomingchao/laravel-follow)[ Packagist](https://packagist.org/packages/raomingchao/oc-laravel-follow)[ RSS](/packages/raomingchao-oc-laravel-follow/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (9)Used By (0)

Laravel 5 Follow System
=======================

[](#laravel-5-follow-system)

❤️ This package helps you to add user based follow system to your model.

[![Build Status](https://camo.githubusercontent.com/c601ee737863ccce64adbce39527d1dd65f967c386b20a5c07f8ae7b3419f2f1/68747470733a2f2f7472617669732d63692e6f72672f6f766572747275652f6c61726176656c2d666f6c6c6f772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/overtrue/laravel-follow)[![Latest Stable Version](https://camo.githubusercontent.com/71cc1eca2202f6bf9ca9fb4eebd1fb050d0b601e7a2b3946661b741fcba6f249/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d666f6c6c6f772f762f737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-follow)[![Latest Unstable Version](https://camo.githubusercontent.com/e38875130ff4d49c125eb299d634f0707d73779c7c092c150afeb229adf45e4d/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d666f6c6c6f772f762f756e737461626c652e737667)](https://packagist.org/packages/overtrue/laravel-follow)[![Build Status](https://camo.githubusercontent.com/70012871b1f3519fcd34135f898c3c690cf9212117f3681076f79a4ac410ff84/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f6c61726176656c2d666f6c6c6f772f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/laravel-follow/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/692c5bfcace74033c36ec7dbe556a2414824f74b055be2f34e2299f7ce1a643a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f6c61726176656c2d666f6c6c6f772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/laravel-follow/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/6d7123892d02f29589f8f6701d311e5b77c66041b0a60bef97f11b02185929ae/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6f766572747275652f6c61726176656c2d666f6c6c6f772f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/overtrue/laravel-follow/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/31d8c72d9d58e17500daa8919681b4291aacd7a438ff44ef311fb2aa73dad722/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d666f6c6c6f772f646f776e6c6f616473)](https://packagist.org/packages/overtrue/laravel-follow)[![License](https://camo.githubusercontent.com/66bd0ede32b58beacb2660d3542e3c6bfe9944c7c278b2962e0b7483d3b94a83/68747470733a2f2f706f7365722e707567782e6f72672f6f766572747275652f6c61726176656c2d666f6c6c6f772f6c6963656e7365)](https://packagist.org/packages/overtrue/laravel-follow)

Features
--------

[](#features)

- Support actions:
    - Follow
    - Like
    - Subscribe
    - Favorite
    - Vote (Upvote &amp; Downvote)

Installation
------------

[](#installation)

You can install the package using composer

```
$ composer require overtrue/laravel-follow -vvv
```

Then add the service provider to `config/app.php`

```
Overtrue\LaravelFollow\FollowServiceProvider::class
```

Publish the migrations file:

```
$ php artisan vendor:publish --provider='Overtrue\LaravelFollow\FollowServiceProvider' --tag="migrations"
```

As optional if you want to modify the default configuration, you can publish the configuration file:

```
$ php artisan vendor:publish --provider='Overtrue\LaravelFollow\FollowServiceProvider' --tag="config"
```

And create tables:

```
$ php artisan migrate
```

Finally, add feature trait into User model:

```
use Overtrue\LaravelFollow\Traits\CanFollow;
use Overtrue\LaravelFollow\Traits\CanBeFollowed;

class User extends Model
{
    use CanFollow, CanBeFollowed;
}
```

Usage
-----

[](#usage)

Add `CanXXX` Traits to User model.

```
use Overtrue\LaravelFollow\Traits\CanFollow;
use Overtrue\LaravelFollow\Traits\CanLike;
use Overtrue\LaravelFollow\Traits\CanFavorite;
use Overtrue\LaravelFollow\Traits\CanSubscribe;
use Overtrue\LaravelFollow\Traits\CanVote;

class User extends Model
{
    use CanFollow, CanLike, CanFavorite, CanSubscribe, CanVote;
}
```

Add `CanBeXXX` Trait to target model, such as 'Post' or 'Music' ...:

```
use Overtrue\LaravelFollow\Traits\CanBeLiked;
use Overtrue\LaravelFollow\Traits\CanBeFavorited;
use Overtrue\LaravelFollow\Traits\CanBeVoted;

class Post extends Model
{
    use CanBeLiked, CanBeFavorited, CanBeVoted;
}
```

All available APIs are listed below.

### Follow

[](#follow)

#### `\Overtrue\LaravelFollow\Traits\CanFollow`

[](#overtruelaravelfollowtraitscanfollow)

```
$user->follow($targets)
$user->unfollow($targets)
$user->toggleFollow($targets)
$user->followings()->get() // App\User:class
$user->followings(App\Post::class)->get()
$user->isFollowing($target)
```

#### `\Overtrue\LaravelFollow\Traits\CanBeFollowed`

[](#overtruelaravelfollowtraitscanbefollowed)

```
$object->followers()->get()
$object->isFollowedBy($user)
```

### Like

[](#like)

#### `\Overtrue\LaravelFollow\Traits\CanLike`

[](#overtruelaravelfollowtraitscanlike)

```
$user->like($targets)
$user->unlike($targets)
$user->toggleLike($targets)
$user->hasLiked($target)
$user->likes()->get() // default object: App\User:class
$user->likes(App\Post::class)->get()
```

#### `\Overtrue\LaravelFollow\Traits\CanBeLiked`

[](#overtruelaravelfollowtraitscanbeliked)

```
$object->likers()->get() // or $object->likers
$object->fans()->get() // or $object->fans
$object->isLikedBy($user)
```

### Favorite

[](#favorite)

#### `\Overtrue\LaravelFollow\Traits\CanFavorite`

[](#overtruelaravelfollowtraitscanfavorite)

```
$user->favorite($targets)
$user->unfavorite($targets)
$user->toggleFavorite($targets)
$user->hasFavorited($target)
$user->favorites()->get() // App\User:class
$user->favorites(App\Post::class)->get()
```

#### `\Overtrue\LaravelFollow\Traits\CanBeFavorited`

[](#overtruelaravelfollowtraitscanbefavorited)

```
$object->favoriters()->get() // or $object->favoriters
$object->isFavoritedBy($user)
```

### Subscribe

[](#subscribe)

#### `\Overtrue\LaravelFollow\Traits\CanSubscribe`

[](#overtruelaravelfollowtraitscansubscribe)

```
$user->subscribe($targets)
$user->unsubscribe($targets)
$user->toggleSubscribe($targets)
$user->hasSubscribed($target)
$user->subscriptions()->get() // default object: App\User:class
$user->subscriptions(App\Post::class)->get()
```

#### `Overtrue\LaravelFollow\Traits\CanBeSubscribed`

[](#overtruelaravelfollowtraitscanbesubscribed)

```
$object->subscribers() // or $object->subscribers
$object->isSubscribedBy($user)
```

### Vote

[](#vote)

#### `\Overtrue\LaravelFollow\Traits\CanVote`

[](#overtruelaravelfollowtraitscanvote)

```
$user->vote($target) // Vote with 'upvote' for default
$user->upvote($target)
$user->downvote($target)
$user->cancelVote($target)
$user->hasUpvoted($target)
$user->hasDownvoted($target)
$user->votes(App\Post::class)->get()
$user->upvotes(App\Post::class)->get()
$user->downvotes(App\Post::class)->get()
```

#### `\Overtrue\LaravelFollow\Traits\CanBeVoted`

[](#overtruelaravelfollowtraitscanbevoted)

```
$object->voters()->get()
$object->upvoters()->get()
$object->downvoters()->get()
$object->isVotedBy($user)
$object->isUpvotedBy($user)
$object->isDownvotedBy($user)
```

### Parameters

[](#parameters)

All of the above mentioned methods of creating relationships, such as 'follow', 'like', 'unfollow', 'unlike', their syntax is as follows:

```
follow(array|int|\Illuminate\Database\Eloquent\Model $targets, $class = __CLASS__)
```

So you can call them like this:

```
// Id / Id array
$user->follow(1); // targets: 1, $class = App\User
$user->follow(1, App\Post::class); // targets: 1, $class = App\Post
$user->follow([1, 2, 3]); // targets: [1, 2, 3], $class = App\User

// Model
$post = App\Post::find(7);
$user->follow($post); // targets: $post->id, $class = App\Post

// Model array
$posts = App\Post::popular()->get();
$user->follow($posts); // targets: [1, 2, ...], $class = App\Post
```

### Query relations

[](#query-relations)

```
$followers = $user->followers
$followers = $user->followers()->where('id', '>', 10)->get()
$followers = $user->followers()->orderByDesc('id')->get()
```

The other is the same usage.

### Working with model.

[](#working-with-model)

```
use Overtrue\LaravelFollow\FollowRelation;

// get most popular object

// all types
$relations = FollowRelation::popular()->get();

// followable_type = App\Post
$relations = FollowRelation::popular(App\Post::class)->get();

// followable_type = App\User
$relations = FollowRelation::popular('user')->get();

// followable_type = App\Post
$relations = FollowRelation::popular('post')->get();

// Pagination
$relations = FollowRelation::popular(App\Post::class)->paginate(15);
```

License
-------

[](#license)

MIT

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 85.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~79 days

Total

7

Last Release

2991d ago

PHP version history (2 changes)1.0PHP &gt;=5.4

1.1.0PHP &gt;=5.5.9

### Community

Maintainers

![](https://www.gravatar.com/avatar/811628623fc28c4edc6379e1b5dc2f77cd845020690c9e5f3ed97bb9cc05b0e0?d=identicon)[Misael](/maintainers/Misael)

---

Top Contributors

[![overtrue](https://avatars.githubusercontent.com/u/1472352?v=4)](https://github.com/overtrue "overtrue (63 commits)")[![p3yman](https://avatars.githubusercontent.com/u/2673262?v=4)](https://github.com/p3yman "p3yman (4 commits)")[![jcc](https://avatars.githubusercontent.com/u/12684082?v=4)](https://github.com/jcc "jcc (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (2 commits)")[![entimm](https://avatars.githubusercontent.com/u/1958077?v=4)](https://github.com/entimm "entimm (1 commits)")[![raomingchao](https://avatars.githubusercontent.com/u/7949453?v=4)](https://github.com/raomingchao "raomingchao (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/raomingchao-oc-laravel-follow/health.svg)

```
[![Health](https://phpackages.com/badges/raomingchao-oc-laravel-follow/health.svg)](https://phpackages.com/packages/raomingchao-oc-laravel-follow)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
