hypefactors/laravel-follow
A Laravel package that adds follow and unfollow behavior to Eloquent models. Let users follow other users or any model, retrieve followers and following lists, check relationships, and count followers through a simple, polymorphic API.
Architecture fit
CanFollow on the actor, Followable on the target) plus a single polymorphic pivot table (followers with follower_id/type and followable_id/type). It sits directly in the application's persistence layer with no service, queue, or external dependency.Integration feasibility
composer require hypefactors/laravel-follow, publish config + migration, migrate, add the traits. Integration surface is small and reversible; a credible spike is 1–2 engineer-days including authorization wiring and API exposure.followers(), followings(), isFollowing(), count helpers), so it composes with policies/gates and API resources rather than fighting them.Technical risk
Key questions
Followed/Unfollowed events for notifications, auditing, and cache invalidation?Stack fit
Migration path
follower_*/followable_*, backfill, and run a dual-write or cutover window. Backfill is a straightforward INSERT ... SELECT but must dedupe and be idempotent.Compatibility
composer.json and add a CI job that runs the trait's behavior on the targeted Laravel major. If the project is on Laravel 11/12 or PHP 8.3+, validate before committing; otherwise vendor/fork the two traits (permissive license makes this viable).string key lengths for UUIDs, and collation consistency between the pivot and target tables.Sequencing
withCount conventions and a cache strategy for counts.Maintenance
Support
Scaling
followersCount/followingsCount on the model, refreshed on follow/unfollow or via queued job).follower_id/type, followable_id/type); paginate follower/following lists with cursor pagination.Failure modes
Ramp-up
How can I help you explore Laravel packages today?