Download the PHP package timgavin/laravel-follow without Composer
On this page you can find all versions of the php package timgavin/laravel-follow. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timgavin/laravel-follow
More information about timgavin/laravel-follow
Files in timgavin/laravel-follow
Package laravel-follow
Short Description A User can follow another User
License MIT
Homepage https://github.com/timgavin/laravel-follow
Informations about the package laravel-follow
Laravel Follow
A simple Laravel package for following users.
Requirements
- PHP 8.3 or greater
- Laravel 12 or greater
Installation
Via Composer
Import Laravel Follow into your User model and add the trait.
Then run migrations.
Configuration
Publish the config file.
Available options:
Usage
Follow a user
Returns true if the user was followed, false if already following.
Unfollow a user
Returns true if the user was unfollowed, false if not following.
Toggle follow
Returns true if now following, false if unfollowed.
Check if a user is following another user
Check if a user is followed by another user
Check if users are mutually following each other
Check if there is any follow relationship between two users
Get following count
Get followers count
Get the users a user is following
Get the users a user is following with pagination
Get the users who are following a user
Get the users who are following a user with pagination
Get the most recent users who are following a user
Get an array of IDs of the users a user is following
Get an array of IDs of the users who are following a user
Get an array of IDs of both following and followers
Get all user IDs involved in any follow relationship (single query)
Returns IDs of users you're following AND users following you.
Get follow status for multiple users in batch
Returns status for multiple users in just 2 queries instead of 2N. Useful for API responses.
Get follow status for a single user
Returns bidirectional follow status in a single query. Useful for profile pages.
Query Scopes
Exclude follow-related users from queries
Excludes users involved in any follow relationship with the given user.
Relationships
Access the follows relationship (users this user is following).
Access the followers relationship (users following this user).
Get the follow relationship record where this user follows another.
Get the follow relationship record where another user follows this user.
Get all follow relationships between two users.
Caching
Cache the IDs of the users a user is following. Default duration is set in config.
Get the cached IDs of the users a user is following.
Cache the IDs of the users who are following a user.
Get the cached IDs of the users who are following a user.
Clear the Following cache.
Clear the Followers cache.
Clear the Followers cache for another user. Useful after following a user to keep their followers cache in sync.
Clear the Following cache for another user.
Note: The cache is automatically cleared when calling follow() or unfollow(). However, only the current user's cache is cleared. Use clearFollowersCacheFor() to clear the target user's followers cache if needed.
Events
Events are dispatched when users follow or unfollow each other.
Disable events in config.
Query Scopes
Query scopes are available on the Follow model.
Upgrading
If upgrading from 1.x, please see the upgrade guide.
Change log
Please see the changelog for more information on what has changed recently.
Testing
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
License
MIT. Please see the license file for more information.