lecturize/laravel-followers
Add follow/unfollow relationships to any Eloquent model in Laravel. Traits let models follow and be followed polymorphically, with helpers like follow(), unfollow(), toggleFollow(), isFollowing(), plus followers() and following() relations and query scopes.
Architecture fit
CanFollow / CanBeFollowed) applied to any model. This composes with existing domain models rather than imposing a new one — low architectural footprint.Integration feasibility
composer require, publish config/migrations, add traits to target models, run migrations. Realistically a half-day spike and 2–5 days to production-grade for a single team.follows/followers table, and the need to add composite indexes and a uniqueness constraint the package likely does not ship.Technical risk
Key questions
composer.json constraints, and do they include our target?(follower_type, follower_id, followable_type, followable_id)? If not, duplicate follows are a data-integrity bug we inherit.Stack fit
Migration path
*_type with morph-map aliases, not FQCNs, and register those aliases via Relation::morphMap() before backfilling — otherwise every subsequent refactor of a namespace silently breaks relations.FollowRepository/service that wraps the trait calls. That gives a single seam to swap in a fork or a bespoke implementation later.Compatibility
composer.json constraints against our PHP (8.1/8.2/8.3) and Laravel versions. If unsupported, choose deliberately between (a) pinning the framework, (b) forking with widened constraints, or (c) reimplementing the ~200 lines in-house. For a package at this maturity level, (b) or (c) is usually correct.Sequencing
Maintenance
^ on a dormant package) and let Dependabot surface constraint drift. Semver discipline in a single-maintainer project is not a guarantee.Support
Scaling
(follower_type, follower_id) and (followable_type, followable_id); both are read paths for "who do I follow" and "who follows me."withCount on polymorphic relations is workable at low cardinality but degrades for high-follower accounts. Beyond roughly 10k followers per entity, denormalize counts (counter column or Redis) and reconcile asynchronously.pluck() over the following list. Use chunked, queued fan-out or pull-on-read with caching; the package gives you the relationship, not the feed strategy.Failure modes
Ramp-up
How can I help you explore Laravel packages today?