PHPackages                             akira/laravel-followable - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. akira/laravel-followable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

akira/laravel-followable
========================

 A lightweight and flexible Laravel package that adds follow/unfollow functionality to Eloquent models. With an intuitive API, it allows users to follow other users, track entities, and manage relationships effortlessly.

0.2.1(4mo ago)10580[1 PRs](https://github.com/akira-io/laravel-followable/pulls)MITPHPPHP ^8.3CI passing

Since Feb 9Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/akira-io/laravel-followable)[ Packagist](https://packagist.org/packages/akira/laravel-followable)[ Docs](https://github.com/akira-io/laravel-followable)[ GitHub Sponsors](https://github.com/Akira)[ RSS](/packages/akira-laravel-followable/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelog (4)Dependencies (18)Versions (7)Used By (0)

Laravel Followable
==================

[](#laravel-followable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5a9f8f8ee753cb789987593dcc7f63f2fbcab0ab0c75bc96f47425b3b16b79a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616b6972612f6c61726176656c2d666f6c6c6f7761626c652e737667)](https://packagist.org/packages/akira/laravel-followable)[![Total Downloads](https://camo.githubusercontent.com/55c4f9e5b9dafafd959bee5a61b28647bc4c2d4cf7c540e39e35a57ea1a2e74b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616b6972612f6c61726176656c2d666f6c6c6f7761626c652e737667)](https://packagist.org/packages/akira/laravel-followable)[![PHPStan Level](https://camo.githubusercontent.com/3eef5bfb737c3eb8f74ff340fd46dc7a1cc6a5af7e425296fcec68a1ad6f5ad9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068707374616e2d6c6576656c253230392d627269676874677265656e2e737667)](https://phpstan.org)[![License](https://camo.githubusercontent.com/9f8df5b59bd5b3cdcc1b266967ef5091facc7b389276c0089784778f9765be9d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616b6972612f6c61726176656c2d666f6c6c6f7761626c652e737667)](https://github.com/akira-io/laravel-followable/blob/main/LICENSE)

**Laravel Followable** is a lightweight and flexible Laravel package that adds follow/unfollow functionality to Eloquent models. With an intuitive API, it allows users to follow other users, track entities, and manage relationships effortlessly.

Features
--------

[](#features)

- **Follow/Unfollow Any Model** - Users can follow users, posts, channels, or any Eloquent model
- **Private Accounts** - Built-in approval workflow for follow requests
- **Polymorphic Relationships** - Follow different types of entities seamlessly
- **Query Scopes** - Powerful scopes for filtering and ordering by followers
- **Events** - Listen to `Followed` and `UnFollowed` events
- **Attach Follow Status** - Efficiently add follow status to collections
- **Type-Safe** - PHPStan Level 9 with 100% type coverage
- **Performance** - Optimized queries with eager loading support
- **Well Tested** - Comprehensive test suite with Pest PHP

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11.x or 12.x

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

[](#installation)

Install the package via Composer:

```
composer require akira/laravel-followable
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="followable-migrations"
php artisan migrate
```

Optionally, publish the configuration file:

```
php artisan vendor:publish --tag="followable-config"
```

Quick Start
-----------

[](#quick-start)

### 1. Add Traits to Your Models

[](#1-add-traits-to-your-models)

Add the `Follower` and `Followable` traits to your User model:

```
use Akira\Followable\Concerns\Followable;
use Akira\Followable\Concerns\Follower;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    use Followable, Follower;
}
```

### 2. Follow Users

[](#2-follow-users)

```
$user = User::find(1);
$targetUser = User::find(2);

// Follow a user
$user->follow($targetUser);

// Unfollow a user
$user->unfollow($targetUser);

// Toggle follow
$user->toggleFollow($targetUser);
```

### 3. Check Follow Status

[](#3-check-follow-status)

```
// Check if following
if ($user->isFollowing($targetUser)) {
    echo "You are following this user";
}

// Check if followed by
if ($targetUser->isFollowedBy($user)) {
    echo "This user follows you";
}
```

### 4. Get Followers and Following

[](#4-get-followers-and-following)

```
// Get all followers
$followers = $user->followers;

// Get all following
$following = $user->followings;

// Count followers
$followersCount = $user->followers()->count();

// Get with pagination
$followers = $user->followers()->paginate(20);
```

Private Accounts &amp; Approval Workflow
----------------------------------------

[](#private-accounts--approval-workflow)

Enable follow request approval by overriding the `needsToApproveFollowRequests()` method:

```
class User extends Authenticatable
{
    use Followable, Follower;

    public function needsToApproveFollowRequests(): bool
    {
        return $this->is_private;
    }
}
```

Manage follow requests:

```
// Check if request is pending
if ($user->hasRequestedToFollow($privateUser)) {
    echo "Your follow request is pending approval";
}

// Accept a follow request
$privateUser->acceptFollowRequestFrom($user);

// Reject a follow request
$privateUser->rejectFollowRequestFrom($user);

// Get pending requests
$pendingFollowers = $user->notApprovedFollowers;

// Get approved followers
$approvedFollowers = $user->approvedFollowers;
```

Query Scopes
------------

[](#query-scopes)

Order users by follower count:

```
// Most followed users
$popularUsers = User::orderByFollowersCountDesc()->take(10)->get();

// Least followed users
$newUsers = User::orderByFollowersCountAsc()->take(10)->get();

// With additional filters
$topActiveUsers = User::where('is_active', true)
    ->orderByFollowersCountDesc()
    ->paginate(20);
```

Events
------

[](#events)

Listen to follow/unfollow events:

```
use Akira\Followable\Events\Followed;
use Akira\Followable\Events\UnFollowed;

// In EventServiceProvider
protected $listen = [
    Followed::class => [
        SendFollowNotification::class,
    ],
    UnFollowed::class => [
        RemoveFollowNotification::class,
    ],
];
```

Attach Follow Status
--------------------

[](#attach-follow-status)

Efficiently add follow status to collections:

```
$users = User::all();
auth()->user()->attachFollowStatus($users);

foreach ($users as $user) {
    if ($user->has_followed) {
        echo "Following since {$user->followed_at->diffForHumans()}";
    }
}
```

Documentation
-------------

[](#documentation)

Comprehensive documentation is available in the [`/docs`](docs) directory:

- [Installation Guide](docs/01-installation.md)
- [Configuration](docs/02-configuration.md)
- [Basic Usage](docs/04-basic-usage.md)
- [Follower Trait](docs/05-follower-trait.md)
- [Followable Trait](docs/06-followable-trait.md)
- [Approval Workflow](docs/07-approval-workflow.md)
- [Events](docs/09-events.md)
- [Query Scopes](docs/12-query-scopes.md)
- [Advanced Usage](docs/14-advanced-usage.md)
- [Testing](docs/15-testing.md)
- [API Reference](docs/17-api-reference.md)

**[ View Full Documentation](docs/README.md)**

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

Run specific tests:

```
# Code formatting
composer test:lint

# Static analysis
composer test:types

# Type coverage
composer test:type-coverage

# Unit tests with coverage
composer test:coverage
```

Configuration
-------------

[](#configuration)

The package can be configured via the `config/followable.php` file:

```
return [
    // Use UUIDs instead of auto-incrementing IDs
    'uuids' => false,

    // Custom user foreign key column name
    'user_foreign_key' => 'user_id',

    // Custom table name
    'followables_table' => 'followables',

    // Custom model class
    'followables_model' => \Akira\Followable\Followable::class,
];
```

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Please see [SECURITY.md](SECURITY.md) for our security policy.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details on:

- Development setup
- Coding standards (PSR-12, PHPStan Level 9)
- Testing requirements
- Pull request process

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Credits
-------

[](#credits)

- [kidiatoliny](https://github.com/kidiatoliny)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance84

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.9% 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 ~102 days

Total

5

Last Release

47d ago

Major Versions

0.2.1 → 1.x-dev2026-03-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/c42e59ca0b3864a382dc0c3e290f8cf7d75bbe3eab10a3af0f71d5785f89d0bc?d=identicon)[kidiatoliny](/maintainers/kidiatoliny)

---

Top Contributors

[![kidiatoliny](https://avatars.githubusercontent.com/u/48266788?v=4)](https://github.com/kidiatoliny "kidiatoliny (114 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (14 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (13 commits)")

---

Tags

laravelakirafollowable

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/akira-laravel-followable/health.svg)

```
[![Health](https://phpackages.com/badges/akira-laravel-followable/health.svg)](https://phpackages.com/packages/akira-laravel-followable)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)

PHPackages © 2026

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