ashmawi / laravel-follow
User follow unfollow system for Laravel.
1.0.0
2021-10-04 00:47 UTC
This package is not auto-updated.
Last update: 2025-06-23 14:57:35 UTC
README
Installing
$ composer require ashmawi/laravel-follow
$ php artisan migrate
Configuration
This step is optional
$ php artisan vendor:publish --tag=laravel-follow-config
Migrations
This step is also optional, if you want to custom the pivot table, you can publish the migration files
$ php artisan vendor:publish --tag=laravel-follow-migrations
Usage
Traits
use Ashmawi\LaravelFollow\Traits\Followable; class User extends Authenticatable { use Followable; }
API
$user1->follow($user2); $user1->unfollow($user2); $user1->isFollowing($user2)
Get followings
$user->followings
Get followers
$user->followers
Aggregations
// followings count $user->followings()->count(); // with query where $user->followings()->where('x', 'x')->count(); // followers count $user->followers()->count();