cybercog/laravel-love
Add reactions, likes, votes, and claps to any Eloquent model. Laravel Love provides a flexible, enterprise-ready system for GitHub/Facebook-style reactions with migrations and upgrade guidance, letting users express feelings about your content in minutes.
Cog\Contracts\Love\) and implementations (Cog\Laravel\Love\), making it adaptable to enterprise-grade applications.IncrementReactionAggregatesJob) for scalable reaction counting, reducing database load.love:setup-reactable, love:recount) for zero-downtime migrations and batch processing.love:upgrade-v7-to-v8). Requires careful planning for production adoption.User model) or extended to bots/agents (e.g., Agent model)?love:recount) suffice, or is a dedicated service (e.g., Redis) needed?POST /reactions, GET /posts/{id}/reactions).Reacterable/Reactable traits (e.g., Post, Comment).composer require cybercog/laravel-love.php artisan vendor:publish --provider="Cog\Laravel\Love\LoveServiceProvider".php artisan migrate.use Cog\Laravel\Love\Traits\Reacterable; to user-like models (e.g., User).use Cog\Laravel\Love\Traits\Reactable; to reactable models (e.g., Post).config/love.php:
'reaction_types' => [
'like' => ['mass' => 1, 'weight' => 1],
'dislike' => ['mass' => -1, 'weight' => 1],
'love' => ['mass' => 2, 'weight' => 2],
],
love:upgrade-v7-to-v8 for schema changes (v7→v8).love_reactions and love_reaction_totals.eloquent-observers).php artisan queue:work --sleep=3 --tries=3 --log=/var/log/love-jobs.log
love_reactions, love_reaction_totals) are critical; include them in database backups.love_reactions(reactant_id, reacter_id, reaction_type) for fast lookups.love_reactions by reactant_id if reactions exceed 10M per model.love:*).post:123:reactions) with a short TTL (e.g., 5 mins) to reduce database load.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Queue worker crashes | Stale reaction counters | Implement retry logic with exponential backoff. |
| Database lock during peak load | Timeouts for reaction creation | Use database connection pooling (e.g., PgBouncer). |
| Custom reaction validation fails | Invalid reactions persisted | Add transaction rollback for reaction creation. |
| Cache invalidation delay | Stale reaction counts in UI | Use event listeners to invalidate cache on reaction changes. |
| Schema migration failure | Broken reaction system | Test migrations in staging; use rollback scripts. |
| Third-party API rate limits | Failed external reaction syncs | Implement retry logic with jitter. |
reactions_created, queue_processing_time) via Laravel Telescope or PrometheusHow can I help you explore Laravel packages today?